<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>js-XLSX | 个人笔记</title>
    <meta name="description" content="个人笔记">
    <link rel="stylesheet" href="/vite-vue-blog/assets/style.8f176e54.css">
    <link rel="modulepreload" href="/vite-vue-blog/assets/app.864f9b59.js">
    <link rel="modulepreload" href="/vite-vue-blog/assets/notes_4.library_xlsx_1.文档翻译.md.12943aa2.lean.js">
    <link rel="prefetch" href="/vite-vue-blog/assets/chunks/VPAlgoliaSearchBox.1d33ff4e.js">
    <link rel="icon" href="/vite-vue-blog/logo.svg">
  <link rel="preload" href="/assets/inter-latin.7b37fe23.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  <script>(()=>{const e=localStorage.getItem("vue-theme-appearance");(!e||e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  <script>(()=>{const e=localStorage.getItem("vitepress-theme-appearance"),a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="VPApp" data-v-73d720b3><!--[--><span tabindex="-1" data-v-9a0c1eda></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-9a0c1eda> Skip to content </a><!--]--><!----><!--[--><!--]--><header class="VPNav nav-bar" data-v-73d720b3 data-v-665b4326><div class="VPNavBar" data-v-665b4326 data-v-22c1e5cc><div class="container" data-v-22c1e5cc><a class="VPNavBarTitle" href="/vite-vue-blog/" data-v-22c1e5cc data-v-734a10ac><h1 class="text" data-v-734a10ac>个人笔记</h1></a><div class="content" data-v-22c1e5cc><!----><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-22c1e5cc data-v-03d04f32><span id="main-nav-aria-label" class="visually-hidden" data-v-03d04f32>Main Navigation</span><!--[--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">javaScript <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/1.javaScript/typescript/1.%E4%BB%8B%E7%BB%8D%E4%B8%8E%E5%AE%89%E8%A3%85.html"><!--[-->typescript<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/1.javaScript/%E5%9F%BA%E7%A1%80/1.%E5%9F%BA%E7%A1%80%E8%AF%AD%E6%B3%95.html"><!--[-->基础<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/1.javaScript/%E5%B7%A5%E5%85%B7%E5%87%BD%E6%95%B0/10.%E5%B7%A5%E5%85%B7%E5%87%BD%E6%95%B0.html"><!--[-->工具函数<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">basic <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/1.html/1.%E5%9F%BA%E7%A1%80.html"><!--[-->html<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/2.css/1.%E5%9F%BA%E7%A1%80.html"><!--[-->css<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/5.node/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->node<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/6.http/2.http.html"><!--[-->http<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/7.git/github.html"><!--[-->git<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/8.java/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->java<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/2.basic/9.%E7%AE%97%E6%B3%95/1.%E5%9F%BA%E7%A1%80.html"><!--[-->算法<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">framework <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/10.react/1.%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA%E4%B8%8E%E9%85%8D%E7%BD%AE.html"><!--[-->react<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/3.express/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->express<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/3.vue/12.vitepress.html"><!--[-->vue<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/4.uniapp/1.%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE.html"><!--[-->uniapp<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/5.electron/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->electron<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/6.%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/1.%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE.html"><!--[-->微信小程序<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/7.%E4%B9%BE%E5%9D%A4/1.%E5%89%8D%E7%BD%AE%E7%9F%A5%E8%AF%86.html"><!--[-->乾坤<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/3.framework/koa/redis.html"><!--[-->koa<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">library <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/Autoprefixer/1.%E5%9F%BA%E7%A1%80.html"><!--[-->Autoprefixer<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/eharts/1.vue%E4%B8%AD%E4%BD%BF%E7%94%A8.html"><!--[-->eharts<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/logic-flow/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->logic-flow<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/Monaco-Editor/Monaco-Editor.html"><!--[-->Monaco-Editor<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/cheerio.html"><!--[-->node包<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/xlsx/1.%E6%96%87%E6%A1%A3%E7%BF%BB%E8%AF%91.html"><!--[-->xlsx<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/4.library/%E5%BE%85%E6%95%B4%E7%90%86/axios.html"><!--[-->待整理<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">build <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/5.build/1.webpack/1.%E8%B5%B7%E6%AD%A5.html"><!--[-->webpack<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/5.build/2.rollup/1.%E4%BB%8B%E7%BB%8D.html"><!--[-->rollup<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/5.build/3.babel/3.babel.html"><!--[-->babel<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/5.build/4.server/4.%E4%B8%8A%E7%BA%BF.html"><!--[-->server<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="vt-flyout VPNavBarMenuGroup" data-v-03d04f32 data-v-6671b864><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false"><span class="vt-flyout-button-text">all <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-text-icon"><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="vt-flyout-menu"><div class="vt-menu"><div class="vt-menu-items"><!--[--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/6.all/3.just-start/2.mongodb.html"><!--[-->just-start<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/6.all/4.solve-problems/postmon.html"><!--[-->solve-problems<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/6.all/4.vscode/1.vscode%E4%BD%BF%E7%94%A8.html"><!--[-->vscode<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/6.all/English/%E5%AD%A6%E4%B9%A0%E5%AD%A6%E4%B9%A0.html"><!--[-->English<!--]--><!----></a><!--]--><!--[--><a class="vt-link link vt-menu-link" href="/vite-vue-blog/notes/6.all/Snabbdom/1.%E6%BA%90%E7%A0%81%E8%A7%A3%E8%AF%BB.html"><!--[-->Snabbdom<!--]--><!----></a><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><div class="VPNavBarAppearance appearance" data-v-22c1e5cc data-v-4a42e18e><button class="vt-switch vt-switch-appearance" type="button" role="switch" aria-label="toggle dark mode" data-v-4a42e18e><span class="vt-switch-check"><span class="vt-switch-icon"><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-switch-appearance-sun"><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-switch-appearance-moon"><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="vt-social-links VPNavBarSocialLinks social-links" data-v-22c1e5cc data-v-16262ec2><!--[--><a class="vt-social-link is-small" href="https://github.com/zqy233/vite-vue-blog" title="github" target="_blank" rel="noopener noreferrer"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-social-link-icon"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg><span class="visually-hidden">github</span></a><!--]--></div><div class="vt-flyout VPNavBarExtra extra" data-v-22c1e5cc data-v-0e7e8326><button type="button" class="vt-flyout-button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-flyout-button-icon"><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="vt-flyout-menu"><div class="vt-menu"><!----><!--[--><!--[--><div class="vt-menu-group" data-v-0e7e8326><div class="vt-menu-item item" data-v-0e7e8326><p class="vt-menu-label" data-v-0e7e8326>明暗</p><div class="vt-menu-action action" data-v-0e7e8326><button class="vt-switch vt-switch-appearance" type="button" role="switch" aria-label="toggle dark mode" data-v-0e7e8326><span class="vt-switch-check"><span class="vt-switch-icon"><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-switch-appearance-sun"><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-switch-appearance-moon"><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="vt-menu-group" data-v-0e7e8326><div class="vt-menu-item item" data-v-0e7e8326><div class="vt-social-links social-links" data-v-0e7e8326><!--[--><a class="vt-social-link is-small" href="https://github.com/zqy233/vite-vue-blog" title="github" target="_blank" rel="noopener noreferrer"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-social-link-icon"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path></svg><span class="visually-hidden">github</span></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><button type="button" class="vt-hamburger VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-22c1e5cc data-v-60965b98><span class="vt-hamburger-container"><span class="vt-hamburger-top"></span><span class="vt-hamburger-middle"></span><span class="vt-hamburger-bottom"></span></span></button></div></div></div><!----></header><div class="VPLocalNav" data-v-73d720b3 data-v-acbefcb0><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-acbefcb0><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-acbefcb0><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-acbefcb0>目录</span></button><a class="top-link" href="#" data-v-acbefcb0>回到顶部</a></div><aside class="VPSidebar" data-v-73d720b3 data-v-137f95ea><nav id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-137f95ea><!--[--><!--]--><span id="sidebar-aria-label" class="visually-hidden" data-v-137f95ea>Sidebar Navigation </span><!--[--><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>Autoprefixer</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/Autoprefixer/1.%E5%9F%BA%E7%A1%80.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>基础</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>eharts</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/eharts/1.vue%E4%B8%AD%E4%BD%BF%E7%94%A8.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>vue中使用</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/2.react%E4%B8%AD%E4%BD%BF%E7%94%A8.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>react中使用</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/3.%E9%80%9A%E7%94%A8.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>通用</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/4.%E9%A5%BC%E5%9B%BE.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>饼图</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/5.%E6%9F%B1%E7%8A%B6%E5%9B%BE.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>柱状图</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/6.%E6%8A%98%E7%BA%BF%E5%9B%BE.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>折线图</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/7.tooltip.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>tooltip</p></a><a class="link" href="/vite-vue-blog/notes/4.library/eharts/8.%E5%9C%B0%E5%9B%BE.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>地图</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>logic-flow</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/logic-flow/1.%E8%B5%B7%E6%AD%A5.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>起步</p></a><a class="link" href="/vite-vue-blog/notes/4.library/logic-flow/3.%E7%94%A8%E6%B3%95.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>用法</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>Monaco-Editor</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/Monaco-Editor/Monaco-Editor.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>Monaco-Editor</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>node包</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/cheerio.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>cheerio</p></a><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/docsify.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>docsify</p></a><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/npm-check.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>npm-check</p></a><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/npm-run-all.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>npm-run-all</p></a><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/tsup.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>tsup</p></a><a class="link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/%E8%84%9A%E6%9C%AC.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>脚本</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="active title-text" data-v-0ce3abb6>xlsx</h2></div><!--[--><a class="link active" href="/vite-vue-blog/notes/4.library/xlsx/1.%E6%96%87%E6%A1%A3%E7%BF%BB%E8%AF%91.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>文档翻译</p></a><a class="link" href="/vite-vue-blog/notes/4.library/xlsx/2.%E5%AD%A6%E4%B9%A0xlsx.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>学习xlsx</p></a><!--]--></section></div><div class="group" data-v-137f95ea><section class="VPSidebarGroup" data-v-137f95ea data-v-0ce3abb6><div class="title" data-v-0ce3abb6><h2 class="title-text" data-v-0ce3abb6>待整理</h2></div><!--[--><a class="link" href="/vite-vue-blog/notes/4.library/%E5%BE%85%E6%95%B4%E7%90%86/axios.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>axios</p></a><a class="link" href="/vite-vue-blog/notes/4.library/%E5%BE%85%E6%95%B4%E7%90%86/dayjs.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>dayjs</p></a><a class="link" href="/vite-vue-blog/notes/4.library/%E5%BE%85%E6%95%B4%E7%90%86/prettier.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>prettier</p></a><a class="link" href="/vite-vue-blog/notes/4.library/%E5%BE%85%E6%95%B4%E7%90%86/vxe-table.html" data-v-0ce3abb6 data-v-539850a2><p class="link-text" data-v-539850a2>vxe-table</p></a><!--]--></section></div><!--]--><!--[--><!--]--></nav></aside><div id="VPContent" class="VPContent has-sidebar" data-v-73d720b3 data-v-f1570ab6><div class="VPContentDoc has-aside has-sidebar" data-v-f1570ab6 data-v-6971fa12><div class="container" data-v-6971fa12><div class="aside" data-v-6971fa12><div class="aside-container" data-v-6971fa12><!--[--><!--]--><div class="VPContentDocOutline" data-v-6971fa12 data-v-6706ac52><div class="outline-marker" data-v-6706ac52></div><div class="outline-title" data-v-6706ac52>索引</div><nav aria-labelledby="doc-outline-aria-label" data-v-6706ac52><span id="doc-outline-aria-label" class="visually-hidden" data-v-6706ac52>Table of Contents for current page</span><ul class="root" data-v-6706ac52><!--[--><li style="" data-v-6706ac52><a class="outline-link" href="#sheetjs" data-v-6706ac52>SheetJS</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#起步" data-v-6706ac52>起步</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#用法" data-v-6706ac52>用法</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#sheetjs的理念-禅" data-v-6706ac52>Sheetjs的理念(禅)</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#示例：json生成workbook" data-v-6706ac52>示例：JSON生成workbook</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#js生态系统演示" data-v-6706ac52>JS生态系统演示</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#获取和提取数据" data-v-6706ac52>获取和提取数据</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#打包和发布数据" data-v-6706ac52>打包和发布数据</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#接口" data-v-6706ac52>接口</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#通用电子表格格式" data-v-6706ac52>通用电子表格格式</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#解析选项" data-v-6706ac52>解析选项</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#写入选项" data-v-6706ac52>写入选项</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#utility-实用-函数列表" data-v-6706ac52>Utility(实用)函数列表</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#二维数组输入" data-v-6706ac52>二维数组输入</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#数组对象输入" data-v-6706ac52>数组对象输入</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#json" data-v-6706ac52>JSON</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#文件格式" data-v-6706ac52>文件格式</a><!----></li><li style="" data-v-6706ac52><a class="outline-link" href="#许可" data-v-6706ac52>许可</a><!----></li><!--]--></ul></nav></div><!--[--><!--]--><!----><!--[--><!--]--></div></div><div class="content" data-v-6971fa12><!--[--><!--]--><main data-v-6971fa12><div style="position:relative;" class="vt-doc notes" data-v-6971fa12><div><h1 id="js-xlsx" tabindex="-1">js-XLSX <a class="header-anchor" href="#js-xlsx" aria-hidden="true">#</a></h1><p><code>xlsx</code>是由<code>SheetJS</code>开发的一个处理excel文件的npm库</p><p>适用于前端开发者实现导入导出excel文件的经典需求</p><p>为了区别于xlsx文件，突出其应用语言，该库通常又被称为<code>js-xlsx</code></p><blockquote><p>以下内容翻译于<code>xlsx</code>官方README文档，可能存在一定翻译错误，欢迎指出</p><p>部分章节，如测试，贡献，引用等不翻译</p><p>官方README文档地址https://www.npmjs.com/package/xlsx</p></blockquote><h2 id="sheetjs" tabindex="-1">SheetJS <a class="header-anchor" href="#sheetjs" aria-hidden="true">#</a></h2><p>SheetJS社区版提供了经受过考验的开源解决方案，可以从几乎任何复杂的电子表格中提取有用的数据，并生成新的电子表格，这些表格将与传统和现代软件一起使用</p><p>SheetJS Pro提供了数据处理之外的解决方案：轻松编辑复杂模板；通过造型展现你内心的毕加索；制作带有图像/图表/数据透视表的自定义表格；评估公式表达式和web应用程序的端口计算；自动化常见的电子表格任务等等</p><h2 id="起步" tabindex="-1">起步 <a class="header-anchor" href="#起步" aria-hidden="true">#</a></h2><h3 id="下载" tabindex="-1">下载 <a class="header-anchor" href="#下载" aria-hidden="true">#</a></h3><h4 id="独立的浏览器脚本" tabindex="-1">独立的浏览器脚本 <a class="header-anchor" href="#独立的浏览器脚本" aria-hidden="true">#</a></h4><p>完整且独立的浏览器脚本，保存在dist/xlsx.full.min.js中，可以直接用script标签添加到页面</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">lang</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">javascript</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">dist/xlsx.full.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span></code></pre></div><h4 id="可用的cdn" tabindex="-1">可用的cdn <a class="header-anchor" href="#可用的cdn" aria-hidden="true">#</a></h4><table><thead><tr><th>CDN</th><th>URL</th></tr></thead><tbody><tr><td><code>unpkg</code></td><td><a href="https://unpkg.com/xlsx/" target="_blank" rel="noopener noreferrer">https://unpkg.com/xlsx/</a></td></tr><tr><td><code>jsDelivr</code></td><td><a href="https://jsdelivr.com/package/npm/xlsx" target="_blank" rel="noopener noreferrer">https://jsdelivr.com/package/npm/xlsx</a></td></tr><tr><td><code>CDNjs</code></td><td><a href="https://cdnjs.com/libraries/xlsx" target="_blank" rel="noopener noreferrer">https://cdnjs.com/libraries/xlsx</a></td></tr></tbody></table><p>如下示例，通过unpkg使用最新版的xlsx</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://unpkg.com/xlsx/dist/xlsx.full.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span></code></pre></div><h4 id="浏览器构建" tabindex="-1">浏览器构建 <a class="header-anchor" href="#浏览器构建" aria-hidden="true">#</a></h4><p>完整的单文件版本为dist/xlsx.full.min.js dist/xlsx.core.min.js省略了代码页库（不支持XLS编码） 一个更纤细的版本保存在dist/xlsx.mini.min.js，与完整版本相比：</p><ul><li>省略了代码页库（不支持XLS编码）</li><li>不支持XLSB/XLS/Lotus 1-2-3/SpreadsheetML 2003/Numbers</li><li>删除了node流工具</li></ul><p>使用<a href="https://bower.io/search/?q=js-xlsx" target="_blank" rel="noopener noreferrer">bower</a>:</p><div class="language-sh"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">$ bower install js-xlsx</span></span>
<span class="line"></span></code></pre></div><h4 id="ecmascript-模块" tabindex="-1">ECMAScript 模块 <a class="header-anchor" href="#ecmascript-模块" aria-hidden="true">#</a></h4><p>ECMAScript模块版本名为xlsx.mjs，可以使用type=module来直接添加到包含&lt;script&gt;标签的页面：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">type</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">module</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">import </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> read</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> writeFileXLSX </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> from &quot;./xlsx.mjs&quot;;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">/* 加载代码页支持库以扩展对旧格式的支持 */</span></span>
<span class="line"><span style="color:#A6ACCD;">import </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> set_cptable </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> from &quot;./xlsx.mjs&quot;;</span></span>
<span class="line"><span style="color:#A6ACCD;">import * as cptable from &#39;./dist/cpexcel.full.mjs&#39;;</span></span>
<span class="line"><span style="color:#A6ACCD;">set_cptable(cptable);</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span></code></pre></div><p>xlsx的npm包也提供了这些函数，可以用在Angular和其他框架中</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">read</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">writeFileXLSX</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">xlsx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* 加载代码页支持库以扩展对旧格式的支持  */</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">set_cptable</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">xlsx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> cptable </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">xlsx/dist/cpexcel.full.mjs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#82AAFF;">set_cptable</span><span style="color:#A6ACCD;">(cptable)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h4 id="deno" tabindex="-1">Deno <a class="header-anchor" href="#deno" aria-hidden="true">#</a></h4><p>xlsx.mjs能被Deno导入，可以使用unpkg</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">// @deno-types=&quot;https://unpkg.com/xlsx/types/index.d.ts&quot;</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> XLSX </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">https://unpkg.com/xlsx/xlsx.mjs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* load the codepage support library for extended support with older formats  */</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> cptable </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">https://unpkg.com/xlsx/dist/cpexcel.full.mjs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">set_cptable</span><span style="color:#A6ACCD;">(cptable)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h4 id="nodejs" tabindex="-1">NodeJS <a class="header-anchor" href="#nodejs" aria-hidden="true">#</a></h4><p>使用npm</p><div class="language-sh"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">$ npm install xlsx</span></span>
<span class="line"></span></code></pre></div><p>默认情况下，支持require：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> XLSX </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">require</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">xlsx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>还可以用xlsx.mjs来使用import</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> XLSX </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">xlsx/xlsx.mjs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* load &#39;fs&#39; for readFile and writeFile support */</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> fs </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">fs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">set_fs</span><span style="color:#A6ACCD;">(fs)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* load &#39;stream&#39; for stream support */</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">Readable</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">stream</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">stream</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">set_readable</span><span style="color:#A6ACCD;">(Readable)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* load the codepage support library for extended support with older formats  */</span></span>
<span class="line"><span style="color:#89DDFF;font-style:italic;">import</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">*</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> cpexcel </span><span style="color:#89DDFF;font-style:italic;">from</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">xlsx/dist/cpexcel.full.mjs</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">set_cptable</span><span style="color:#A6ACCD;">(cpexcel)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h4 id="photoshop与indesign" tabindex="-1">Photoshop与InDesign <a class="header-anchor" href="#photoshop与indesign" aria-hidden="true">#</a></h4><p>dist/xlsx.extendscript.js是一个用于Photoshop和InDesign的ExtendScript构建，包含在npm包中。它可以直接引用一个#include指令：</p><div class="language-sh"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">#include &quot;xlsx.extendscript.js&quot;</span></span>
<span class="line"></span></code></pre></div><h4 id="internet-explorer和ecmascript-3的兼容性" tabindex="-1">Internet Explorer和ECMAScript 3的兼容性 <a class="header-anchor" href="#internet-explorer和ecmascript-3的兼容性" aria-hidden="true">#</a></h4><p>为了与JavaScript引擎广泛兼容，该库使用ECMAScript 3语言方言以及一些ES5功能（如Array#forEach）编写。较旧的浏览器需要垫片来提供缺失的功能</p><p>要使用垫片，请在加载xlsx.js的script标签之前添加垫片</p><div class="language-html"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">&lt;!-- add the shim first --&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">type</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">text/javascript</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">shim.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">&lt;!-- after the shim is referenced, add the library --&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">type</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">text/javascript</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">xlsx.full.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span></code></pre></div><p>该脚本还包括IE_LoadFile和IE_SaveFile，用于在Internet Explorer版本6-9中加载和保存文件。xlsx.extendscript.js打包垫片来适用于Photoshop和其他Adobe产品的格式</p><h2 id="用法" tabindex="-1">用法 <a class="header-anchor" href="#用法" aria-hidden="true">#</a></h2><p>大多数涉及电子表格和数据的场景可分为5个部分：</p><ul><li><code>1.获取数据</code>：数据可以存储在任何地方：本地或远程文件、数据库、HTML表，甚至在web浏览器中以编程方式生成</li><li><code>2.提取数据</code>：对于电子表格文件，这涉及到解析原始字节以读取单元格数据。对于一般的JS数据，这涉及重塑数据</li><li><code>3.处理数据</code>：从生成汇总统计数据到清理数据记录，这一步是问题的核心</li><li><code>4.打包数据</code>：这可能涉及制作新的电子表格或使用JSON序列化。为UI工具字符串化或编写XML或简单地扁平化数据</li><li><code>5.发布数据</code>：电子表格文件可以上传到服务器或在本地写入。数据可以在HTML表格或数据网格中呈现给用户</li></ul><p>一个常见情景，把存储在HTML表中的数据生成有效的电子表格导出。在下方示例中，页面上的一个HTML表将被使用，底部将添加一行日期，生成一个新xlsb文件并在本地下载。XLSX.writeFile负责打包数据并尝试本地下载：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">// Acquire Data (reference to the HTML table)</span></span>
<span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> table_elt </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> document</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">getElementById</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">my-table-id</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// Extract Data (create a workbook object from the table)</span></span>
<span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">table_to_book</span><span style="color:#A6ACCD;">(table_elt)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// Process Data (add a new row)</span></span>
<span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> ws </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> workbook</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">Sheets[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Sheet1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(ws</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Created </span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">+new</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">Date</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">toISOString</span><span style="color:#A6ACCD;">()]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:-</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">// Package and Release Data (`writeFile` tries to write and save an XLSB file)</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">writeFile</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Report.xlsb</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>该库尝试使用函数来简化步骤2和4，从电子表格文件（读/读文件）中提取有用的数据，并从数据（写/写文件）中生成新的电子表格文件。其他实用程序函数（如<code>table_to_book</code>）与其他常见数据源（如HTML表格）配合使用</p><p>本文档和各种演示项目涵盖了步骤1和5的一些常见场景和方法</p><p>实用功能有助于完成第3步</p><ul><li><code>获取和提取数据</code>章节描述了常见数据导入场景的解决方案</li><li><code>打包和发布数据</code>章节描述了常见数据导出场景的解决方案</li><li><code>Utility(实用)函数列表</code>章节详细介绍了将JSON数组和其他常见JS结构转换为工作表对象的实用函数</li></ul><h2 id="sheetjs的理念-禅" tabindex="-1">Sheetjs的理念(禅) <a class="header-anchor" href="#sheetjs的理念-禅" aria-hidden="true">#</a></h2><p>数据处理应该适合任何工作流</p><p>本库不强制推行单独的生命周期。它非常适合使用任何框架构建的网站和应用程序。简单的JS数据对象将很好地与Web开发者和未来的浏览器API配合</p><p>JavaScript是一种强大的数据处理语言</p><p><code>通用电子表格格式</code>是<code>workbook</code>核心概念的简单对象表示。库中的各种函数提供了处理对象的低级工具</p><p>为了友好的JS处理，有一些<code>utility(实用) </code>函数用于将<code>worksheet</code>的部分转换为数组或从数组中转换。以下示例将功能强大的JS数组方法与网络请求库相结合，下载数据、选择所需信息并创建<code>workbook</code>文件</p><h2 id="示例：json生成workbook" tabindex="-1">示例：JSON生成workbook <a class="header-anchor" href="#示例：json生成workbook" aria-hidden="true">#</a></h2><p>目标是生成一个包含美国总统姓名和生日的xlsx文件</p><h3 id="_1-获取数据" tabindex="-1">1.获取数据 <a class="header-anchor" href="#_1-获取数据" aria-hidden="true">#</a></h3><h4 id="原始数据" tabindex="-1">原始数据 <a class="header-anchor" href="#原始数据" aria-hidden="true">#</a></h4><p><a href="https://theunitedstates.io/congress-legislators/executive.json%E5%85%B7%E6%9C%89%E6%89%80%E9%9C%80%E7%9A%84%E6%95%B0%E6%8D%AE%E3%80%82%E4%BE%8B%E5%A6%82%EF%BC%8CJohn" target="_blank" rel="noopener noreferrer">https://theunitedstates.io/congress-legislators/executive.json具有所需的数据。例如，John</a> Adams：</p><div class="language-json"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">John Adams</span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C792EA;">id</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">/* (data omitted) */</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C792EA;">name</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">first</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">John</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;">          </span><span style="color:#676E95;font-style:italic;">// &lt;-- first name</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">last</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Adams</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">           </span><span style="color:#676E95;font-style:italic;">// &lt;-- last name</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C792EA;">bio</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">birthday</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1735-10-19</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// &lt;-- birthday</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">gender</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">M</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C792EA;">terms</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">[</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">type</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">viceprez</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">/* (other fields omitted) */</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">type</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">viceprez</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">/* (other fields omitted) */</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#FFCB6B;">type</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">prez</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">/* (other fields omitted) */</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// &lt;-- look for &quot;prez&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">]</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span>
<span class="line"></span></code></pre></div><h4 id="筛选总统" tabindex="-1">筛选总统 <a class="header-anchor" href="#筛选总统" aria-hidden="true">#</a></h4><p>原始数据包含Aaron Burr，一位从未当过总统的副总统！</p><p>需要通过数组方法<code>filter</code>来创建一个新数组，一位总统至少任期一届，字段名为“prez”。为了测试是否至少有一个“prez”项，使用数组的<code>some</code>方法。完整的过滤函数：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> prez </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> raw_data</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">filter</span><span style="color:#A6ACCD;">(row </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">terms</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">some</span><span style="color:#A6ACCD;">(term </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> term</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">type </span><span style="color:#89DDFF;">===</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">prez</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">))</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h4 id="整理数据" tabindex="-1">整理数据 <a class="header-anchor" href="#整理数据" aria-hidden="true">#</a></h4><p>在本例中，姓名是名与姓<code>row.name.first+&quot; &quot;+row.name.last</code>的组合，生日字段<code>row.bio.birthday</code>。使用数组的map方法，对数据进行整理：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> rows </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> prez</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(row </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">first </span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">last</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">birthday</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">bio</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">birthday</span></span>
<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">))</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>结果是一个没有嵌套的“简单”对象数组：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">[</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">George Washington</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">birthday</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1732-02-22</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">John Adams</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">birthday</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1735-10-19</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#89DDFF;">  </span><span style="color:#676E95;font-style:italic;">// ... one row per President</span></span>
<span class="line"><span style="color:#A6ACCD;">]</span></span>
<span class="line"></span></code></pre></div><h3 id="_2-提取数据" tabindex="-1">2.提取数据 <a class="header-anchor" href="#_2-提取数据" aria-hidden="true">#</a></h3><p>使用处理过的数据，<code>XLSX.utils.json_to_sheet</code>生成一个<code>worksheet</code></p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> worksheet </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">json_to_sheet</span><span style="color:#A6ACCD;">(rows)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>XLSX.utils.book_new</code>创建一个新的<code>workbook</code>且<code>XLSX.utils.book_append_sheet</code>添加一个<code>worksheet</code>到<code>workbook</code>中。这个新的<code>worksheet</code>会被命名为<code>Dates</code></p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">book_new</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">book_append_sheet</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Dates</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h3 id="_3-处理数据" tabindex="-1">3.处理数据 <a class="header-anchor" href="#_3-处理数据" aria-hidden="true">#</a></h3><h4 id="固定标题行" tabindex="-1">固定标题行 <a class="header-anchor" href="#固定标题行" aria-hidden="true">#</a></h4><p>默认情况下，<code>json_to_sheet</code>会创建一个带有标题行的<code>worksheet</code>。在本例中，标题行来自JS对象键：”name&quot;和&quot;birthday&quot;</p><p>标题位于单元格A1和B1中。<code>XLSX.utils.sheet_add_aoa</code>可以从单元格A1开始将文本值写入现有工作表：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Name</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Birthday</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h4 id="固定列宽" tabindex="-1">固定列宽 <a class="header-anchor" href="#固定列宽" aria-hidden="true">#</a></h4><p>有些名称的长度超过默认列宽。列宽通过设置<code>!cols</code> <code>worksheet</code>属性设置</p><p>将A列的宽度设置为大约10个字符：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">worksheet[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!cols</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">] </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [ </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">wch</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">10</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> ]</span><span style="color:#89DDFF;">;</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"></span></code></pre></div><p>使用数组的reduce方法来计算最大宽度</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> max_width </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> rows</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">reduce</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">w</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> r</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> Math</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">max</span><span style="color:#A6ACCD;">(w</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> r</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">length)</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">10</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#A6ACCD;">worksheet[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!cols</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">] </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [ </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">wch</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> max_width </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;"> ]</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>注意：如果起点是文件或HTML表，<code>XLSX.utils.sheet_to_json</code>将生成一个JS对象数组</p><h3 id="_4-打包和发布数据" tabindex="-1">4.打包和发布数据 <a class="header-anchor" href="#_4-打包和发布数据" aria-hidden="true">#</a></h3><p><code>XLSX.writeFile</code>创建电子表格文件并尝试将其写入系统。在浏览器中，它将尝试提示用户下载文件。在NodeJS中，它将写入本地目录</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">writeFile</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Presidents.xlsx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h3 id="完整示例" tabindex="-1">完整示例 <a class="header-anchor" href="#完整示例" aria-hidden="true">#</a></h3><p>PS：以下代码经过测试，是可以正常使用于国内网络的</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;">&lt;!</span><span style="color:#A6ACCD;">DOCTYPE html</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">html</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">lang</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">en</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">head</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">meta</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">charset</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">UTF-8</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> /&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">meta</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">http-equiv</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">X-UA-Compatible</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">content</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">IE=edge</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> /&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">meta</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">name</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">viewport</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">content</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">width=device-width, initial-scale=1.0</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;"> /&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">title</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">Document</span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">title</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    // 导入xlsx</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://unpkg.com/xlsx/dist/xlsx.full.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    // 导入axios</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;"> </span><span style="color:#C792EA;">src</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://unpkg.com/axios/dist/axios.min.js</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">      //取消注释下一行以便在NodeJS中使用：</span></span>
<span class="line"><span style="color:#A6ACCD;">      //const XLSX=require（“XLSX”）、axios=require（“axios”）；</span></span>
<span class="line"><span style="color:#A6ACCD;">      ;(async () =&gt; </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* fetch JSON data and parse */</span></span>
<span class="line"><span style="color:#A6ACCD;">        const url </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://theunitedstates.io/congress-legislators/executive.json</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">        const raw_data </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;font-style:italic;">await</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">axios</span><span style="color:#A6ACCD;">(url</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">responseType</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">json</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">))</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">data</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* filter for the Presidents */</span></span>
<span class="line"><span style="color:#A6ACCD;">        const prez </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> raw_data</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">filter</span><span style="color:#A6ACCD;">(row </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">terms</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">some</span><span style="color:#A6ACCD;">(term </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> term</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">type </span><span style="color:#89DDFF;">===</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">prez</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">))</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* flatten objects */</span></span>
<span class="line"><span style="color:#A6ACCD;">        const rows </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> prez</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">map</span><span style="color:#A6ACCD;">(row </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">name</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">first </span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">+</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">last</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">          </span><span style="color:#F07178;">birthday</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> row</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">bio</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">birthday</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">))</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* generate worksheet and workbook */</span></span>
<span class="line"><span style="color:#A6ACCD;">        const worksheet </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">json_to_sheet</span><span style="color:#A6ACCD;">(rows)</span></span>
<span class="line"><span style="color:#A6ACCD;">        const workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">book_new</span><span style="color:#A6ACCD;">()</span></span>
<span class="line"><span style="color:#A6ACCD;">        XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">book_append_sheet</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Dates</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* fix headers */</span></span>
<span class="line"><span style="color:#A6ACCD;">        XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Name</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Birthday</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* calculate column width */</span></span>
<span class="line"><span style="color:#A6ACCD;">        const max_width </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> rows</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">reduce</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">w</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> r</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> Math</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">max</span><span style="color:#A6ACCD;">(w</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> r</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">length)</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">10</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#A6ACCD;">        worksheet[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!cols</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">] </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">{</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">wch</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> max_width </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#676E95;font-style:italic;">/* create an XLSX file and try to save to Presidents.xlsx */</span></span>
<span class="line"><span style="color:#A6ACCD;">        XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">writeFile</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Presidents.xlsx</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">)</span></span>
<span class="line"><span style="color:#A6ACCD;">      </span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)()</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">script</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">head</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">body</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">    </span><span style="color:#89DDFF;">&lt;</span><span style="color:#F07178;">style</span><span style="color:#89DDFF;">&gt;&lt;/</span><span style="color:#F07178;">style</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">body</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#89DDFF;">&lt;/</span><span style="color:#F07178;">html</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span></code></pre></div><h3 id="文件格式实现细节" tabindex="-1">文件格式实现细节 <a class="header-anchor" href="#文件格式实现细节" aria-hidden="true">#</a></h3><p>解析器涵盖了各种常见的电子表格文件格式，以确保“HTML另存为XLS”文件能与实际的XLS或XLSX文件一样工作</p><p>为了与数据生态系统广泛兼容，writer支持多种常见的输出格式</p><p>尽可能使数据处理代码不必担心涉及特定文件格式</p><h2 id="js生态系统演示" tabindex="-1">JS生态系统演示 <a class="header-anchor" href="#js生态系统演示" aria-hidden="true">#</a></h2><p><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/" target="_blank" rel="noopener noreferrer"><code>demos</code> directory</a>包括以下项目的示例：</p><h3 id="框架和api" tabindex="-1">框架和API <a class="header-anchor" href="#框架和api" aria-hidden="true">#</a></h3><ul><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/angular/" target="_blank" rel="noopener noreferrer"><code>angularjs</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/angular2/" target="_blank" rel="noopener noreferrer"><code>angular and ionic</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/knockout/" target="_blank" rel="noopener noreferrer"><code>knockout</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/meteor/" target="_blank" rel="noopener noreferrer"><code>meteor</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/react/" target="_blank" rel="noopener noreferrer"><code>react and react-native</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/vue/" target="_blank" rel="noopener noreferrer"><code>vue 2.x and weex</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/xhr/" target="_blank" rel="noopener noreferrer"><code>XMLHttpRequest and fetch</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/server/" target="_blank" rel="noopener noreferrer"><code>nodejs server</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/database/" target="_blank" rel="noopener noreferrer"><code>databases and key/value stores</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/array/" target="_blank" rel="noopener noreferrer"><code>typed arrays and math</code></a></li></ul><h3 id="打包工具" tabindex="-1">打包工具 <a class="header-anchor" href="#打包工具" aria-hidden="true">#</a></h3><ul><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/browserify/" target="_blank" rel="noopener noreferrer"><code>browserify</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/fusebox/" target="_blank" rel="noopener noreferrer"><code>fusebox</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/parcel/" target="_blank" rel="noopener noreferrer"><code>parcel</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/requirejs/" target="_blank" rel="noopener noreferrer"><code>requirejs</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/rollup/" target="_blank" rel="noopener noreferrer"><code>rollup</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/systemjs/" target="_blank" rel="noopener noreferrer"><code>systemjs</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/typescript/" target="_blank" rel="noopener noreferrer"><code>typescript</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/webpack/" target="_blank" rel="noopener noreferrer"><code>webpack 2.x</code></a></li></ul><h3 id="平台和集成" tabindex="-1">平台和集成 <a class="header-anchor" href="#平台和集成" aria-hidden="true">#</a></h3><ul><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/deno/" target="_blank" rel="noopener noreferrer"><code>deno</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/electron/" target="_blank" rel="noopener noreferrer"><code>electron application</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/nwjs/" target="_blank" rel="noopener noreferrer"><code>nw.js application</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/chrome/" target="_blank" rel="noopener noreferrer"><code>Chrome / Chromium extensions</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/google-sheet/" target="_blank" rel="noopener noreferrer"><code>Download a Google Sheet locally</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/extendscript/" target="_blank" rel="noopener noreferrer"><code>Adobe ExtendScript</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/headless/" target="_blank" rel="noopener noreferrer"><code>Headless Browsers</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/datagrid/" target="_blank" rel="noopener noreferrer"><code>canvas-datagrid</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/xspreadsheet/" target="_blank" rel="noopener noreferrer"><code>x-spreadsheet</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/react/modify/" target="_blank" rel="noopener noreferrer"><code>react-data-grid</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/vue/modify/" target="_blank" rel="noopener noreferrer"><code>vue3-table-light</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/altjs/" target="_blank" rel="noopener noreferrer"><code>Swift JSC and other engines</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/function/" target="_blank" rel="noopener noreferrer"><code>&quot;serverless&quot; functions</code></a></li><li><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/oldie/" target="_blank" rel="noopener noreferrer"><code>internet explorer</code></a></li></ul><p>其他示例在<a href="https://github.com/SheetJS/sheetjs/blob/HEAD/demos/showcase/" target="_blank" rel="noopener noreferrer">showcase</a></p><p><a href="https://sheetjs.com/demos/modify.html%E6%98%BE%E7%A4%BA%E4%BA%86%E8%AF%BB%E5%8F%96%E3%80%81%E4%BF%AE%E6%94%B9%E5%92%8C%E5%86%99%E5%85%A5%E6%96%87%E4%BB%B6%E7%9A%84%E5%AE%8C%E6%95%B4%E7%A4%BA%E4%BE%8B" target="_blank" rel="noopener noreferrer">https://sheetjs.com/demos/modify.html显示了读取、修改和写入文件的完整示例</a></p><p><a href="https://github.com/SheetJS/sheetjs/blob/HEAD/bin/xlsx.njs%E6%98%AF%E7%94%A8%E4%BA%8Enode%E4%B8%AD%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%B7%A5%E5%85%B7%EF%BC%8C%E7%94%A8%E4%BA%8E%E8%AF%BB%E5%8F%96%E7%94%B5%E5%AD%90%E8%A1%A8%E6%A0%BC%E6%96%87%E4%BB%B6%E5%B9%B6%E4%BB%A5%E5%90%84%E7%A7%8D%E6%A0%BC%E5%BC%8F%E5%AF%BC%E5%87%BA%E5%86%85%E5%AE%B9" target="_blank" rel="noopener noreferrer">https://github.com/SheetJS/sheetjs/blob/HEAD/bin/xlsx.njs是用于node中命令行工具，用于读取电子表格文件并以各种格式导出内容</a></p><h2 id="获取和提取数据" tabindex="-1">获取和提取数据 <a class="header-anchor" href="#获取和提取数据" aria-hidden="true">#</a></h2><h3 id="解析workbook" tabindex="-1">解析<code>workbook</code> <a class="header-anchor" href="#解析workbook" aria-hidden="true">#</a></h3><h4 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-hidden="true">#</a></h4><h5 id="从电子表格字节中提取数据" tabindex="-1">从电子表格字节中提取数据 <a class="header-anchor" href="#从电子表格字节中提取数据" aria-hidden="true">#</a></h5><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">read</span><span style="color:#A6ACCD;">(data</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>**<code>read</code>**方法可以从存储在JS字符串、二进制字符串、NodeJS缓冲区或类型化数组（Uint8Array或ArrayBuffer）中的电子表格字节中提取数据</p><h5 id="从本地文件读取电子表格字节并提取数据" tabindex="-1">从本地文件读取电子表格字节并提取数据 <a class="header-anchor" href="#从本地文件读取电子表格字节并提取数据" aria-hidden="true">#</a></h5><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">readFile</span><span style="color:#A6ACCD;">(filename</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>**<code>readFile</code>**方法尝试通过提供的路径来读取电子表格文件。<strong>浏览器端</strong>通常不允许以这种方式读取文件（这被认为是一种安全风险），<strong>浏览器端</strong>尝试以这种方式读取文件会引发错误</p><p>第二个opts参数是可选的。之后的<code>解析选项</code>表格涵盖了支持的属性和行为</p><h3 id="处理json和js数据" tabindex="-1">处理JSON和JS数据 <a class="header-anchor" href="#处理json和js数据" aria-hidden="true">#</a></h3><p>JSON和JS数据往往表示单个<code>worksheet</code>, 本节将使用一些<code>utility</code>函数来生成<code>workbook</code></p><h5 id="创建新workbook" tabindex="-1">创建新<code>workbook</code> <a class="header-anchor" href="#创建新workbook" aria-hidden="true">#</a></h5><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> workbook </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">book_new</span><span style="color:#A6ACCD;">()</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><strong><code>book_new</code></strong> <code>utility</code>函数创建一个没有<code>worksheet</code>的<code>workbook</code> 通常，在电子表格软件中至少需要一个<code>workbook</code>，它们会在用户界面中强制执行此要求，所以本库在写入时强制执行该要求，如果将空<code>workbook</code>传递给写入函数，直接报错</p><h4 id="api-1" tabindex="-1">API <a class="header-anchor" href="#api-1" aria-hidden="true">#</a></h4><h5 id="使用js二维数组创建worksheet" tabindex="-1">使用JS二维数组创建<code>worksheet</code> <a class="header-anchor" href="#使用js二维数组创建worksheet" aria-hidden="true">#</a></h5><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> worksheet </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">aoa_to_sheet</span><span style="color:#A6ACCD;">(aoa</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>aoa_to_sheet</code> <code>utility</code>函数按以行为主的顺序遍历“二维数组”，生成一个<code>worksheet</code>对象。以下代码段生成了一个工作表，其中单元格A1设置为字符串A1，单元格B1设置为B1，以此类推：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> worksheet </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">aoa_to_sheet</span><span style="color:#A6ACCD;">([</span></span>
<span class="line"><span style="color:#A6ACCD;">  [</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">B1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">C1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  [</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">B2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">C2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  [</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A3</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">B3</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">C3</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">])</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>二维数组输入</code>章节描述了这个函数和可选<code>opts</code>参数的更多细节</p><h5 id="使用js对象数组创建worksheet" tabindex="-1">使用JS对象数组创建<code>worksheet</code> <a class="header-anchor" href="#使用js对象数组创建worksheet" aria-hidden="true">#</a></h5><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> worksheet </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">json_to_sheet</span><span style="color:#A6ACCD;">(jsa</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>json_to_sheet</code> <code>utility</code>函数按顺序遍历一组JS数组对象，生成一个<code>worksheet</code>对象，默认情况下，它会生成一个标题行且把数组的每个对象作为一行，可选的<code>opts</code>参数拥有控制列顺序和标题输出的设置</p><p><code>数组对象输入</code>章节更详细地描述了该函数和可选的<code>opts</code>参数</p><h2 id="打包和发布数据" tabindex="-1">打包和发布数据 <a class="header-anchor" href="#打包和发布数据" aria-hidden="true">#</a></h2><h4 id="写入workbook" tabindex="-1">写入<code>Workbook</code> <a class="header-anchor" href="#写入workbook" aria-hidden="true">#</a></h4><h4 id="api-2" tabindex="-1">API <a class="header-anchor" href="#api-2" aria-hidden="true">#</a></h4><h4 id="从数据生成电子表格字节（文件）" tabindex="-1"><em>从数据生成电子表格字节（文件）</em> <a class="header-anchor" href="#从数据生成电子表格字节（文件）" aria-hidden="true">#</a></h4><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> data </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">write</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>write</code>方法尝试将<code>Workbook</code>中的数据打包到内存的文件中。默认情况下，会生成XLSX文件，但这可以通过<code>opts</code>参数的<code>bookType</code>属性进行控制。根据类型选项，数据可以存储为“二进制字符串”、JS字符串、Uint8Array或缓冲区</p><p>第二个opts参数是必需的。<code>写入选项</code>章节涵盖支持的属性和行为</p><h4 id="生成并尝试保存文件" tabindex="-1"><em>生成并尝试保存文件</em> <a class="header-anchor" href="#生成并尝试保存文件" aria-hidden="true">#</a></h4><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">writeFile</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> filename</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>writeFile方法打包数据并尝试保存新文件。导出文件格式由文件名的扩展名决定（SheetJS.xlsx表示xlsx导出、SheetJS.xlsb表示xlsb导出等）</p><p>writeFile方法使用特定平台的API来启动文件保存。在NodeJS中，fs.readFileSync可以创建一个文件。在web浏览器中，尝试使用HTML5 download属性进行下载，并为IE提供回落(<code>callback</code>)</p><h4 id="生成并尝试保存xlsx文件" tabindex="-1"><em>生成并尝试保存XLSX文件</em> <a class="header-anchor" href="#生成并尝试保存xlsx文件" aria-hidden="true">#</a></h4><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">writeFileXLSX</span><span style="color:#A6ACCD;">(workbook</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> filename</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>writeFile方法嵌入了许多不同的导出函数。这对开发人员的体验很好，但不利于目前的开发工具进行tree shaking。当只需要XLSX导出时，此方法避免引用其他导出函数</p><p>第二个opts参数是可选的。<code>写入选项</code>章节涵盖支持的属性和行为</p><h4 id="流式写入" tabindex="-1"><em>流式写入</em> <a class="header-anchor" href="#流式写入" aria-hidden="true">#</a></h4><p>它们采用与普通写入函数相同的参数，但返回一个NodeJS可读流</p><ul><li><code>XLSX.stream.to_csv</code> 是 <code>XLSX.utils.sheet_to_csv</code>的流式版本</li><li><code>XLSX.stream.to_html</code> 是<code>XLSX.utils.sheet_to_html</code> 的流式版本</li><li><code>XLSX.stream.to_json</code> 是<code>XLSX.utils.sheet_to_json</code>的流式版本</li></ul><h4 id="生成json和js数据" tabindex="-1"><em>生成JSON和JS数据</em> <a class="header-anchor" href="#生成json和js数据" aria-hidden="true">#</a></h4><p>JSON和JS数据往往表示单个<code>worksheet</code>。本节中的<code>utility(实用)</code>函数适用于单个工作表</p><p><code>通用电子表格格式</code>章节更详细地描述了对象结构。<code>workbook.SheetNames</code>是包含<code>worksheet</code>名称的有序列表。<code>workbook.Sheets</code>是一个对象，其键是工作表名，其值是工作表对象</p><p>第一个<code>worksheet</code>存储在<code>workbook.Sheets[workbook.SheetNames[0]]</code></p><h4 id="api-3" tabindex="-1">API <a class="header-anchor" href="#api-3" aria-hidden="true">#</a></h4><p>从一个<code>worksheet</code>创建一个JS对象数组</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> jsa </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_to_json</span><span style="color:#A6ACCD;">(worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> opts)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p>从一个<code>worksheet</code>创建一个JS二维数组</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> aoa </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_to_json</span><span style="color:#A6ACCD;">(worksheet</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{...</span><span style="color:#A6ACCD;">opts</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">header</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>sheet_to_json</code> <code>utility(实用)</code>函数按以行为主的顺序遍历<code>worksheet</code>，生成一个对象数组。第二个<code>opts</code>参数控制许多导出决策，包括值的类型（JS值或格式化文本）。<code>JSON</code>章节更详细地描述了该参数</p><p>默认情况下，<code>sheet_to_json</code>扫描第一行并将这些值用作标题。使用<code>header:1</code>选项，该函数将导出一组二维数组值</p><h2 id="接口" tabindex="-1">接口 <a class="header-anchor" href="#接口" aria-hidden="true">#</a></h2><p><code>XLSX</code>是浏览器和Node中的公开变量</p><p><code>XLSX.version</code>是库的版本（由生成脚本添加）</p><p><code>XLSX.SSF</code>是格式库的嵌入式版本</p><h3 id="解析函数" tabindex="-1">解析函数 <a class="header-anchor" href="#解析函数" aria-hidden="true">#</a></h3><p><code>XLSX.read(data, read_opts)</code>尝试解析数据</p><p><code>XLSX.readFile(filename, read_opts)</code>尝试读取文件名并进行解析</p><p>编译选项在<code>编译选项</code>章节进行了描述</p><h3 id="写入函数" tabindex="-1">写入函数 <a class="header-anchor" href="#写入函数" aria-hidden="true">#</a></h3><p><code>XLSX.write(wb, write_opts)</code>尝试编写<code>workbook</code> <code>wb</code></p><p><code>XLSX.writeFile(wb, filename, write_opts)</code>尝试将<code>wb</code>写入文件名。在基于浏览器的环境中，它将尝试强制客户端下载</p><p><code>XLSX.writeFileAsync(wb, filename, o, cb)</code>尝试将<code>wb</code>写入文件名。如果省略了o，编写器将使用第三个参数作为回调</p><p><code>XLSX.stream</code>包含一组<code>流式写入函数</code></p><p>写入选项在<code>写入选项</code>章节进行了描述</p><h3 id="utilities-实用函数" tabindex="-1">Utilities(实用函数) <a class="header-anchor" href="#utilities-实用函数" aria-hidden="true">#</a></h3><p><code>Utilities(实用函数)</code>可从<code>XLSX.utils</code>对象中获取，<code>实用程序功能</code>章节进行了描述：</p><p><strong>创建:</strong></p><ul><li><code>book_new</code> 创建一个空工作簿</li><li><code>book_append_sheet</code>将工作表添加到工作簿</li></ul><p><strong>导入:</strong></p><ul><li><code>aoa_to_sheet</code>将JS二维数组转换为工作表</li><li><code>json_to_sheet</code>将JS对象数组转换为工作表</li><li><code>table_to_sheet</code>将DOM表格元素转换为工作表</li><li><code>sheet_add_aoa</code> 将JS二维数组添加到现有工作表中</li><li><code>sheet_add_json</code>将JS对象数组添加到现有工作表中</li></ul><p><strong>导出:</strong></p><ul><li><code>sheet_to_json</code>将工作表对象转换为JSON对象数组</li><li><code>sheet_to_csv</code>生成分隔符分隔的值输出</li><li><code>sheet_to_txt</code>生成UTF16格式的文本</li><li><code>sheet_to_html</code>生成HTML输出</li><li><code>sheet_to_formulae</code>生成公式列表（带有值回退）</li></ul><p><strong>单元和单元地址操作:</strong></p><ul><li><code>format_cell</code>生成单元格的文本值（使用数字格式）</li><li><code>encode_row / decode_row</code>0索引行和1索引行之间的转换</li><li><code>encode_col / decode_col</code>在0索引列和列名之间转换</li><li><code>encode_cell / decode_cell</code>转换单元格地址</li><li><code>encode_range / decode_range</code>转换单元格范围</li></ul><h2 id="通用电子表格格式" tabindex="-1">通用电子表格格式 <a class="header-anchor" href="#通用电子表格格式" aria-hidden="true">#</a></h2><p>SheetJS符合通用电子表格格式（CSF）：</p><h3 id="一般结构" tabindex="-1">一般结构 <a class="header-anchor" href="#一般结构" aria-hidden="true">#</a></h3><p>单元格地址对象存储为<code>{c:C，r:R}</code>，其中<code>C</code>和<code>R</code>分别是<code>从0开始的索引</code>的列号和行号。例如，单元地址<code>B5</code>由对象<code>{c:1，r:4}</code>表示</p><p>单元格范围对象存储为<code>{s:S，e:E}</code>，其中<code>S</code>是范围中的第一个单元格，<code>E</code>是范围中的最后一个单元格。范围包括在内。例如，范围<code>A3:B7</code>由对象<code>{s:{c:0,r:2},e:{c:1,r:6}</code>表示。<code>utility(实用)</code>函数执行单元格范围的按照以行为主的顺序遍历：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#89DDFF;font-style:italic;">for</span><span style="color:#A6ACCD;">(</span><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> R </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> range</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">s</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">r</span><span style="color:#89DDFF;">;</span><span style="color:#A6ACCD;"> R </span><span style="color:#89DDFF;">&lt;=</span><span style="color:#A6ACCD;"> range</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">r</span><span style="color:#89DDFF;">;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">++</span><span style="color:#A6ACCD;">R) </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;font-style:italic;">for</span><span style="color:#F07178;">(</span><span style="color:#C792EA;">var</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">C</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">=</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">range</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">s</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">c</span><span style="color:#89DDFF;">;</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">C</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">&lt;=</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">range</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">c</span><span style="color:#89DDFF;">;</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">++</span><span style="color:#A6ACCD;">C</span><span style="color:#F07178;">) </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#F07178;">    </span><span style="color:#C792EA;">var</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">cell_address</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">=</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">c</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;">C</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;"> r</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;">R</span><span style="color:#89DDFF;">};</span></span>
<span class="line"><span style="color:#F07178;">    </span><span style="color:#676E95;font-style:italic;">/* if an A1-style address is needed, encode the address */</span></span>
<span class="line"><span style="color:#F07178;">    </span><span style="color:#C792EA;">var</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">cell_ref</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">=</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">encode_cell</span><span style="color:#F07178;">(</span><span style="color:#A6ACCD;">cell_address</span><span style="color:#F07178;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"><span style="color:#F07178;">  </span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span>
<span class="line"></span></code></pre></div><h3 id="cell对象" tabindex="-1"><code>cell</code>对象 <a class="header-anchor" href="#cell对象" aria-hidden="true">#</a></h3><p><code>cell</code>对象是简单的JS对象，其键和值遵循约定：</p><table><thead><tr><th>Key</th><th>描述</th></tr></thead><tbody><tr><td><code>v</code></td><td>原始值（有关更多信息，请参见数据类型部分）</td></tr><tr><td><code>w</code></td><td>格式化文本（如适用）</td></tr><tr><td><code>t</code></td><td>类型：b布尔值、e错误、n编号、d日期、s文本、z存根</td></tr><tr><td><code>f</code></td><td>编码为A1样式字符串的单元格公式（如果适用）</td></tr><tr><td><code>F</code></td><td>如果公式为数组公式，则封闭数组的范围（如果适用）</td></tr><tr><td><code>D</code></td><td>如果为true，则数组公式是动态的（如果适用）</td></tr><tr><td><code>r</code></td><td>富文本编码（如果适用）</td></tr><tr><td><code>h</code></td><td>富文本的HTML呈现（如果适用）</td></tr><tr><td><code>c</code></td><td>与单元格关联的注释</td></tr><tr><td><code>z</code></td><td>与单元格关联的数字格式字符串（如果请求）</td></tr><tr><td><code>l</code></td><td>单元格超链接对象(<code>.Target</code>控制链接, <code>.Tooltip</code>提示文本)</td></tr><tr><td><code>s</code></td><td>单元的样式/主题（如果适用）</td></tr></tbody></table><h3 id="sheet对象" tabindex="-1"><code>sheet</code>对象 <a class="header-anchor" href="#sheet对象" aria-hidden="true">#</a></h3><p>每个不以<code>!</code>开头的键映射到单元格（使用<code>A-1</code> 表示法）</p><p><code>sheet[address]</code> 返回指定地址的单元格对象</p><p><strong>Special sheet keys (accessible as <code>sheet[key]</code>, each starting with <code>!</code>):</strong></p><ul><li><p><code>sheet[&#39;!ref&#39;]</code>: A-1 based range representing the sheet range. Functions that work with sheets should use this parameter to determine the range. Cells that are assigned outside of the range are not processed. In particular, when writing a sheet by hand, cells outside of the range are not included</p><p>Functions that handle sheets should test for the presence of <code>!ref</code> field. If the <code>!ref</code> is omitted or is not a valid range, functions are free to treat the sheet as empty or attempt to guess the range. The standard utilities that ship with this library treat sheets as empty (for example, the CSV output is empty string).</p><p>When reading a worksheet with the <code>sheetRows</code> property set, the ref parameter will use the restricted range. The original range is set at <code>ws[&#39;!fullref&#39;]</code></p></li><li><p><code>sheet[&#39;!margins&#39;]</code>: 表示页边距的对象。默认值遵循Excel的&quot;normal&quot;预设。Excel也有&quot;wide&quot;和&quot;narrow&quot;预设，但它们会被存储为原始数值。主要属性如下：</p></li></ul><table><thead><tr><th>key</th><th>描述</th><th>&quot;normal&quot;</th><th>&quot;wide&quot;</th><th>&quot;narrow&quot;</th></tr></thead><tbody><tr><td><code>left</code></td><td>left margin (inches)</td><td><code>0.7</code></td><td><code>1.0</code></td><td><code>0.25</code></td></tr><tr><td><code>right</code></td><td>right margin (inches)</td><td><code>0.7</code></td><td><code>1.0</code></td><td><code>0.25</code></td></tr><tr><td><code>top</code></td><td>top margin (inches)</td><td><code>0.75</code></td><td><code>1.0</code></td><td><code>0.75</code></td></tr><tr><td><code>bottom</code></td><td>bottom margin (inches)</td><td><code>0.75</code></td><td><code>1.0</code></td><td><code>0.75</code></td></tr><tr><td><code>header</code></td><td>header margin (inches)</td><td><code>0.3</code></td><td><code>0.5</code></td><td><code>0.3</code></td></tr><tr><td><code>footer</code></td><td>footer margin (inches)</td><td><code>0.3</code></td><td><code>0.5</code></td><td><code>0.3</code></td></tr></tbody></table><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">/* Set worksheet sheet to &quot;normal&quot; */</span></span>
<span class="line"><span style="color:#A6ACCD;">ws[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!margins</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">={</span><span style="color:#F07178;">left</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.7</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">right</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.7</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">top</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.75</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">bottom</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.75</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">header</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.3</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">footer</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.3</span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* Set worksheet sheet to &quot;wide&quot; */</span></span>
<span class="line"><span style="color:#A6ACCD;">ws[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!margins</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">={</span><span style="color:#F07178;">left</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">1.0</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">right</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">1.0</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">top</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">1.0</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">bottom</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">1.0</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">header</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.5</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">footer</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.5</span><span style="color:#89DDFF;">}</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* Set worksheet sheet to &quot;narrow&quot; */</span></span>
<span class="line"><span style="color:#A6ACCD;">ws[</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">!margins</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">={</span><span style="color:#F07178;">left</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.25</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">right</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.25</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">top</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.75</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">bottom</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.75</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">header</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.3</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;">footer</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">0.3</span><span style="color:#89DDFF;">}</span></span>
<span class="line"></span></code></pre></div><h4 id="worksheet对象" tabindex="-1"><code>Worksheet</code>对象 <a class="header-anchor" href="#worksheet对象" aria-hidden="true">#</a></h4><p>除了基础的<code>sheet</code>的<code>keys</code>,<code>worksheet</code>还增加了：</p><ul><li><code>ws[&#39;!cols&#39;]</code>: 列属性对象的数组。列宽实际上是以标准化的方式存储在文件中的，以“最大数字宽度”（渲染数字0-9的最大宽度，以像素为单位）来衡量。解析后，列对象在wpx字段中存储像素宽度，在wch字段中存储字符宽度，在MDW字段中存储最大数字宽度</li><li><code>ws[&#39;!rows&#39;]</code>: 行属性对象的数组，如文档后面所述。每个行对象都对包括行高和可见性在内的属性进行编码</li><li><code>ws[&#39;!merges&#39;]</code>: 与工作表中的合并单元格相对应的范围对象数组。纯文本格式不支持合并单元格。CSV导出将写入合并范围内的所有单元格（如果存在），因此请确保仅设置该范围内的第一个单元格（左上角）</li><li><code>ws[&#39;!outline&#39;]</code>: 配置轮廓的行为方式。选项默认为Excel 2019中的默认设置：</li></ul><table><thead><tr><th>key</th><th>Excel feature</th><th>default</th></tr></thead><tbody><tr><td><code>above</code></td><td>Uncheck &quot;Summary rows below detail&quot;</td><td><code>false</code></td></tr><tr><td><code>left</code></td><td>Uncheck &quot;Summary rows to the right of detail&quot;</td><td><code>false</code></td></tr></tbody></table><ul><li><code>ws[&#39;!protect&#39;]</code>: 写入页保护属性的对象。密码键指定支持密码保护工作表（XLSX/XLSB/XLS）的格式的密码。作者使用了XOR模糊处理方法。以下键控制工作表保护——设置为false可在工作表锁定时启用功能，或设置为true可禁用功能：</li><li><code>ws[&#39;!autofilter&#39;]</code>: 模式下的自动筛选对象：</li></ul><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">type</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">AutoFilter</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#F07178;">ref</span><span style="color:#89DDFF;">:</span><span style="color:#FFCB6B;">string</span><span style="color:#89DDFF;">;</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">// A-1 based range representing the AutoFilter table range</span></span>
<span class="line"><span style="color:#89DDFF;">}</span></span>
<span class="line"></span></code></pre></div><h2 id="解析选项" tabindex="-1">解析选项 <a class="header-anchor" href="#解析选项" aria-hidden="true">#</a></h2><p>The exported <code>read</code> and <code>readFile</code> functions accept an options argument:</p><table><thead><tr><th>Option Name</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td></td><td>Input data encoding (see Input Type below)</td></tr><tr><td><code>raw</code></td><td>false</td><td>If true, plain text parsing will not parse values **</td></tr><tr><td><code>codepage</code></td><td></td><td>If specified, use code page when appropriate **</td></tr><tr><td><code>cellFormula</code></td><td>true</td><td>Save formulae to the .f field</td></tr><tr><td><code>cellHTML</code></td><td>true</td><td>Parse rich text and save HTML to the <code>.h</code> field</td></tr><tr><td><code>cellNF</code></td><td>false</td><td>Save number format string to the <code>.z</code> field</td></tr><tr><td><code>cellStyles</code></td><td>false</td><td>Save style/theme info to the <code>.s</code> field</td></tr><tr><td><code>cellText</code></td><td>true</td><td>Generated formatted text to the <code>.w</code> field</td></tr><tr><td><code>cellDates</code></td><td>false</td><td>Store dates as type <code>d</code> (default is <code>n</code>)</td></tr><tr><td><code>dateNF</code></td><td></td><td>If specified, use the string for date code 14 **</td></tr><tr><td><code>sheetStubs</code></td><td>false</td><td>Create cell objects of type <code>z</code> for stub cells</td></tr><tr><td><code>sheetRows</code></td><td>0</td><td>If &gt;0, read the first <code>sheetRows</code> rows **</td></tr><tr><td><code>bookDeps</code></td><td>false</td><td>If true, parse calculation chains</td></tr><tr><td><code>bookFiles</code></td><td>false</td><td>If true, add raw files to book object **</td></tr><tr><td><code>bookProps</code></td><td>false</td><td>If true, only parse enough to get book metadata **</td></tr><tr><td><code>bookSheets</code></td><td>false</td><td>If true, only parse enough to get the sheet names</td></tr><tr><td><code>bookVBA</code></td><td>false</td><td>If true, copy VBA blob to <code>vbaraw</code> field **</td></tr><tr><td><code>password</code></td><td>&quot;&quot;</td><td>If defined and file is encrypted, use password **</td></tr><tr><td><code>WTF</code></td><td>false</td><td>If true, throw errors on unexpected file features **</td></tr><tr><td><code>sheets</code></td><td></td><td>If specified, only parse specified sheets **</td></tr><tr><td><code>PRN</code></td><td>false</td><td>If true, allow parsing of PRN files **</td></tr><tr><td><code>xlfn</code></td><td>false</td><td>If true, preserve <code>_xlfn.</code> prefixes in formulae **</td></tr><tr><td><code>FS</code></td><td></td><td>DSV Field Separator override</td></tr></tbody></table><h2 id="写入选项" tabindex="-1">写入选项 <a class="header-anchor" href="#写入选项" aria-hidden="true">#</a></h2><p>导出的write和writeFile函数接受选项参数：</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>type</code></td><td></td><td>输出数据编码（参见下面的<code>输出类型</code>）</td></tr><tr><td><code>cellDates</code></td><td><code>false</code></td><td>将日期存储为<code>d</code>（默认值为<code>n</code>）</td></tr><tr><td><code>bookSST</code></td><td><code>false</code></td><td>生成共享字符串表</td></tr><tr><td><code>bookType</code></td><td><code>&quot;xlsx&quot;</code></td><td>工作簿类型（有关支持的格式，请参见下表）</td></tr><tr><td><code>sheet</code></td><td><code>&quot;&quot;</code></td><td>单页格式的工作表名称</td></tr><tr><td><code>compression</code></td><td><code>false</code></td><td>对基于ZIP的格式使用ZIP压缩</td></tr><tr><td><code>Props</code></td><td></td><td>写入时重写工作簿属性</td></tr><tr><td><code>themeXLSX</code></td><td></td><td>在编写XLSX/XLSB/XLSM时重写主题XML</td></tr><tr><td><code>ignoreEC</code></td><td><code>true</code></td><td>抑制“数字为文本”错误</td></tr><tr><td><code>numbers</code></td><td></td><td>用于数字输出的有效载荷</td></tr></tbody></table><ul><li><code>bookSST</code>速度较慢，内存更密集，但与旧版本的iOS数字兼容更好</li><li>原始数据是唯一保证会被保存的东西。README文件中未描述的功能可能无法序列化</li><li><code>cellDates</code>仅适用于XLSX输出，不保证与第三方读卡器配合使用。Excel本身通常不使用类型d写入单元格，因此非Excel工具可能会忽略数据或存在日期的错误。</li><li><code>Props</code>是一个镜像工作簿Props字段的对象。请参阅工作簿文件属性部分的表格</li><li>如果指定，则来自<code>themeXLSX</code>的字符串将被保存为XLSX/XLSB/XLSM文件的主要主题（保存到ZIP中的xl/theme/theme1.xml）</li><li>由于程序中存在缺陷，一些功能，如“文本到列”将使Excel在忽略错误条件的工作表上崩溃。默认情况下，编写器会将文件标记为忽略错误。将<code>ignoreEC</code>设置为false以抑制</li></ul><h3 id="booktype支持的输出格式" tabindex="-1"><code>bookType</code>支持的输出格式 <a class="header-anchor" href="#booktype支持的输出格式" aria-hidden="true">#</a></h3><table><thead><tr><th><code>bookType</code></th><th>文件后缀名</th><th>container</th><th>sheets</th><th>描述</th></tr></thead><tbody><tr><td><code>xlsx</code></td><td><code>.xlsx</code></td><td>ZIP</td><td>multi</td><td>Excel 2007+ XML Format</td></tr><tr><td><code>xlsm</code></td><td><code>.xlsm</code></td><td>ZIP</td><td>multi</td><td>Excel 2007+ Macro XML Format</td></tr><tr><td><code>xlsb</code></td><td><code>.xlsb</code></td><td>ZIP</td><td>multi</td><td>Excel 2007+ Binary Format</td></tr><tr><td><code>biff8</code></td><td><code>.xls</code></td><td>CFB</td><td>multi</td><td>Excel 97-2004 Workbook Format</td></tr><tr><td><code>biff5</code></td><td><code>.xls</code></td><td>CFB</td><td>multi</td><td>Excel 5.0/95 Workbook Format</td></tr><tr><td><code>biff4</code></td><td><code>.xls</code></td><td>none</td><td>single</td><td>Excel 4.0 Worksheet Format</td></tr><tr><td><code>biff3</code></td><td><code>.xls</code></td><td>none</td><td>single</td><td>Excel 3.0 Worksheet Format</td></tr><tr><td><code>biff2</code></td><td><code>.xls</code></td><td>none</td><td>single</td><td>Excel 2.0 Worksheet Format</td></tr><tr><td><code>xlml</code></td><td><code>.xls</code></td><td>none</td><td>multi</td><td>Excel 2003-2004 (SpreadsheetML)</td></tr><tr><td><code>numbers</code></td><td><code>.numbers</code></td><td>ZIP</td><td>single</td><td>Numbers 3.0+ Spreadsheet</td></tr><tr><td><code>ods</code></td><td><code>.ods</code></td><td>ZIP</td><td>multi</td><td>OpenDocument Spreadsheet</td></tr><tr><td><code>fods</code></td><td><code>.fods</code></td><td>none</td><td>multi</td><td>Flat OpenDocument Spreadsheet</td></tr><tr><td><code>wk3</code></td><td><code>.wk3</code></td><td>none</td><td>multi</td><td>Lotus Workbook (WK3)</td></tr><tr><td><code>csv</code></td><td><code>.csv</code></td><td>none</td><td>single</td><td>Comma Separated Values</td></tr><tr><td><code>txt</code></td><td><code>.txt</code></td><td>none</td><td>single</td><td>UTF-16 Unicode Text (TXT)</td></tr><tr><td><code>sylk</code></td><td><code>.sylk</code></td><td>none</td><td>single</td><td>Symbolic Link (SYLK)</td></tr><tr><td><code>html</code></td><td><code>.html</code></td><td>none</td><td>single</td><td>HTML Document</td></tr><tr><td><code>dif</code></td><td><code>.dif</code></td><td>none</td><td>single</td><td>Data Interchange Format (DIF)</td></tr><tr><td><code>dbf</code></td><td><code>.dbf</code></td><td>none</td><td>single</td><td>dBASE II + VFP Extensions (DBF)</td></tr><tr><td><code>wk1</code></td><td><code>.wk1</code></td><td>none</td><td>single</td><td>Lotus Worksheet (WK1)</td></tr><tr><td><code>rtf</code></td><td><code>.rtf</code></td><td>none</td><td>single</td><td>Rich Text Format (RTF)</td></tr><tr><td><code>prn</code></td><td><code>.prn</code></td><td>none</td><td>single</td><td>Lotus Formatted Text</td></tr><tr><td><code>eth</code></td><td><code>.eth</code></td><td>none</td><td>single</td><td>Ethercalc Record Format (ETH)</td></tr></tbody></table><ul><li><code>compression</code> 仅适用于带有ZIP容器的格式</li><li>仅支持单个工作表的格式需要指定工作表的<code>sheet</code>选项。如果字符串为空，则使用第一个工作表</li><li>如果未指定<code>bookType</code>，<code>writeFile</code>将根据文件扩展名自动猜测输出文件格式。它将在上述表格中选择与扩展名匹配的第一种格式</li></ul><h2 id="utility-实用-函数列表" tabindex="-1">Utility(实用)函数列表 <a class="header-anchor" href="#utility-实用-函数列表" aria-hidden="true">#</a></h2><p><code>sheet_to_* </code>系列函数接受一个<code>worksheet</code>和可选选项对象</p><p><code>*_to_sheet </code>系列函数接收一个数据对象和可选选项对象</p><p>示例基于以下工作表：</p><div class="language-sh"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XXX</span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> A </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> B </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> C </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> D </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> E </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> F </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> G </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;">---+---+---+---+---+---+---+---+</span></span>
<span class="line"><span style="color:#A6ACCD;"> 1 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> S </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> h </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> e </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> e </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> t </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> J </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> S </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 1 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 4 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 5 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 6 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 4 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 5 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 6 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 8 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"></span></code></pre></div><h2 id="二维数组输入" tabindex="-1">二维数组输入 <a class="header-anchor" href="#二维数组输入" aria-hidden="true">#</a></h2><p><code>XLSX.utils.aoa_to_sheet</code>函数接收二维数组JS数据，返回一个基于传入数据的<code>worksheet</code>，数字，布尔值和字符串会存储为相应的样式，日期会被存储为日期或数字，<code> Array holes</code>和显式的<code>undefined</code>值将被跳过，<code>null</code>值也许会消失，其他值会被存储为字符串，这个函数接受选项参数：</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>dateNF</code></td><td>FMT 14</td><td>在字符串输出中使用指定的日期格式</td></tr><tr><td><code>cellDates</code></td><td>false</td><td>将日期存储为类型d（默认值为n）</td></tr><tr><td><code>sheetStubs</code></td><td>false</td><td>为空值创建z类型的单元格对象</td></tr><tr><td><code>nullError</code></td><td>false</td><td>如果为真，为null值输出#NULL!错误单元格</td></tr></tbody></table><p>要生成示例工作表，请执行以下代码：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> ws </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">aoa_to_sheet</span><span style="color:#A6ACCD;">([</span></span>
<span class="line"><span style="color:#A6ACCD;">  </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SheetJS</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">split</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&quot;&quot;</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  [</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">6</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">7</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"><span style="color:#A6ACCD;">  [</span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">6</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">7</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">8</span><span style="color:#A6ACCD;">]</span></span>
<span class="line"><span style="color:#A6ACCD;">])</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><p><code>XLSX.utils.sheet_add_aoa</code>使用二维数组的JS数据，更新一个已存在的<code>worksheet</code>对象，它和<code>XLSX.utils.aoa_to_sheet</code>遵循同样的过程，并且接受选项参数：</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>dateNF</code></td><td>FMT 14</td><td>在字符串输出中使用指定的日期格式</td></tr><tr><td><code>cellDates</code></td><td>false</td><td>将日期存储为类型d（默认值为n）</td></tr><tr><td><code>sheetStubs</code></td><td>false</td><td>为空值创建z类型的单元格对象</td></tr><tr><td><code>nullError</code></td><td>false</td><td>如果为真，为空值输出#NULL!错误单元格</td></tr><tr><td><code>origin</code></td><td></td><td>使用指定的单元格作为起点（见下文）</td></tr></tbody></table><p><code>origin</code>可以是下面几种</p><table><thead><tr><th><code>origin</code></th><th>描述</th></tr></thead><tbody><tr><td>(cell object)</td><td>使用指定的单元格（单元格对象）</td></tr><tr><td>(string)</td><td>使用指定的单元格（A1样式单元格）</td></tr><tr><td>(number &gt;= 0)</td><td>从指定行的第一列开始（0-索引）</td></tr><tr><td>-1</td><td>从第一列开始追加到工作表底部</td></tr><tr><td>(default)</td><td>从A1单元开始</td></tr></tbody></table><p>思考这个<code>worksheet</code></p><div class="language-sh"><span class="copy"></span><pre><code><span class="line"><span style="color:#A6ACCD;">XXX</span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> A </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> B </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> C </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> D </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> E </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> F </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> G </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;">---+---+---+---+---+---+---+---+</span></span>
<span class="line"><span style="color:#A6ACCD;"> 1 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> S </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> h </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> e </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> e </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> t </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> J </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> S </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 1 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 5 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 6 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 2 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 6 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 8 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 4 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 3 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 4 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;">   </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 8 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 9 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"><span style="color:#A6ACCD;"> 5 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 4 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 5 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 6 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 7 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 8 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 9 </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> 0 </span><span style="color:#89DDFF;">|</span></span>
<span class="line"></span></code></pre></div><p>此工作表可以按A1:G1、A2:B4、E2:G4、A5:G5的顺序建立：</p><div class="language-js"><span class="copy"></span><pre><code><span class="line"><span style="color:#676E95;font-style:italic;">/* Initial row */</span></span>
<span class="line"><span style="color:#C792EA;">var</span><span style="color:#A6ACCD;"> ws </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">aoa_to_sheet</span><span style="color:#A6ACCD;">([ </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">SheetJS</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">split</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">&quot;&quot;</span><span style="color:#A6ACCD;">) ])</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* Write data starting at A2 */</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(ws</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">2</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">3</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">3</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">4</span><span style="color:#A6ACCD;">]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">A2</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* Write data starting at E2 */</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(ws</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">6</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">7</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">6</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">7</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">8</span><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [</span><span style="color:#F78C6C;">7</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">8</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">9</span><span style="color:#A6ACCD;">]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:{</span><span style="color:#F07178;">r</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">c</span><span style="color:#89DDFF;">:</span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">}}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;">/* Append row */</span></span>
<span class="line"><span style="color:#A6ACCD;">XLSX</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">utils</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">sheet_add_aoa</span><span style="color:#A6ACCD;">(ws</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> [[</span><span style="color:#F78C6C;">4</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">5</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">6</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">7</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">8</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">9</span><span style="color:#89DDFF;">,</span><span style="color:#F78C6C;">0</span><span style="color:#A6ACCD;">]]</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">origin</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">-</span><span style="color:#F78C6C;">1</span><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">;</span></span>
<span class="line"></span></code></pre></div><h2 id="数组对象输入" tabindex="-1">数组对象输入 <a class="header-anchor" href="#数组对象输入" aria-hidden="true">#</a></h2><p><code>XLSX.utils.json_to_sheet</code>接收一个数组对象，自动返回一个<code>worksheet</code>，自动基于对象的所有<code>key</code>生成标题行，默认列顺序由<code>Object.keys</code>所产生数组的key的顺序来决定。该函数接受一个选项参数：</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>header</code></td><td></td><td>使用指定的字段顺序**(默认<code>Object.keys</code>) **</td></tr><tr><td><code>dateNF</code></td><td>FMT 14</td><td>在字符串输出中使用指定的日期格式</td></tr><tr><td><code>cellDates</code></td><td>false</td><td>将日期存储为类型d（默认值为n）</td></tr><tr><td><code>skipHeader</code></td><td>false</td><td>如果为true，则不在输出中包含标题行</td></tr><tr><td><code>nullError</code></td><td>false</td><td>如果为真，为null值输出#NULL!错误单元格</td></tr></tbody></table><ul><li>将写入每行的所有字段。如果header是一个数组，但它不包含特定字段，则该键将附加到数组中</li><li>默认情况下，将跳过Null值。如果<code>nullError</code>为true，则对应的#NULL!错误单元格将被写入<code>worksheet</code></li></ul><p><code>XLSX.utils.sheet_add_json</code>获取对象数组并更新现有<code>worksheet</code>对象。它遵循与<code>json_to_sheet</code>相同的处理，并接受一个选项参数</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>header</code></td><td></td><td>使用指定的字段顺序**(默认<code>Object.keys</code>) **</td></tr><tr><td><code>dateNF</code></td><td>FMT 14</td><td>在字符串输出中使用指定的日期格式</td></tr><tr><td><code>cellDates</code></td><td>false</td><td>将日期存储为类型d（默认值为n）</td></tr><tr><td><code>skipHeader</code></td><td>false</td><td>如果为true，则不在输出中包含标题行</td></tr><tr><td><code>nullError</code></td><td>false</td><td>如果为真，为null值输出#NULL!错误单元格</td></tr><tr><td><code>origin</code></td><td></td><td>使用指定的单元格作为起点（见下文）</td></tr></tbody></table><p><code>origin</code>有以下几种</p><table><thead><tr><th><code>origin</code></th><th>描述</th></tr></thead><tbody><tr><td>(cell object)</td><td>使用指定的单元格（单元格对象）</td></tr><tr><td>(string)</td><td>使用指定的单元格（A1样式单元格）</td></tr><tr><td>(number &gt;= 0)</td><td>从指定行的第一列开始（0-索引）</td></tr><tr><td>-1</td><td>从第一列开始追加到<code>worksheet</code>底部</td></tr><tr><td>(default)</td><td>从A1单元开始</td></tr></tbody></table><h2 id="json" tabindex="-1">JSON <a class="header-anchor" href="#json" aria-hidden="true">#</a></h2><p><code>XLSX.utils.sheet_to_json</code>生成不同类型的JS对象。该函数接受一个选项参数：</p><table><thead><tr><th>选项名</th><th>默认值</th><th>描述</th></tr></thead><tbody><tr><td><code>raw</code></td><td><code>true</code></td><td>使用原始值（true）或格式化字符串（false）</td></tr><tr><td><code>range</code></td><td>from WS</td><td>覆盖范围（见下表）</td></tr><tr><td><code>header</code></td><td></td><td>控制输出格式（见下表）</td></tr><tr><td><code>dateNF</code></td><td>FMT 14</td><td>在字符串输出中使用指定的日期格式</td></tr><tr><td><code>defval</code></td><td></td><td>使用指定值代替null或undefined</td></tr><tr><td><code>blankrows</code></td><td>**</td><td>在输出中包括空行**</td></tr></tbody></table><ul><li><code>raw</code>仅影响具有格式代码（.z）字段或格式文本（.w）字段的单元格</li><li>如果指定了<code>header</code>，则第一行被视为数据行；如果未指定标题，则第一行是标题行，不考虑数据</li><li>未指定<code>header</code>时，转换将通过附加<code>_</code>和从1开始的计数，来自动消除<code>header</code>的歧义。例如，如果三列的标题为<code>foo</code>，则输出字段为<code>foo</code>、<code>foo_1</code>、<code>foo_2</code></li><li>当<code>raw</code>为true时返回<code>null</code>，但当为false时跳过<code>null</code></li><li>如果未指定<code>defval</code>，则通常跳过<code>null</code>和<code>undefined </code>。如果指定，所有<code>null</code>和<code>undefined </code>点都将用<code>defval</code>填充</li><li>当<code>header</code>为1时，默认为生成空行。<code>blankrows</code>必须设置为false才能跳过空白行</li><li>当<code>header</code>不是1时，默认值是跳过空行。<code>blankrows</code>必须为true才能生成空白行</li></ul><p><code>range</code>可以是以下几种</p><table><thead><tr><th><code>range</code></th><th>描述</th></tr></thead><tbody><tr><td>(number)</td><td>使用的<code>worksheet</code>范围，该值作为起始行</td></tr><tr><td>(string)</td><td>使用指定的范围（A1样式有界范围字符串）</td></tr><tr><td>(default)</td><td>使用的<code>worksheet</code>范围（ws[&#39;！ref&#39;]）</td></tr></tbody></table><p><code>header</code>可以是以下几种</p><table><thead><tr><th><code>header</code></th><th>描述</th></tr></thead><tbody><tr><td><code>1</code></td><td>生成一个二维数组（“2D数组”）</td></tr><tr><td><code>&quot;A&quot;</code></td><td>行对象键是文字列标签</td></tr><tr><td>array of strings</td><td>将指定的字符串用作行对象中的键</td></tr><tr><td>(default)</td><td>将第一行作为键读取并消除歧义</td></tr></tbody></table><ul><li>如果<code>header</code>不是1，则row对象将包含不可枚举属性<code>__rowNum__</code>，该属性表示与条目对应的工作表行</li><li>如果header是一个数组，则不会消除键的歧义。如果数组值不唯一，这可能会导致意外的结果！</li></ul><h2 id="文件格式" tabindex="-1">文件格式 <a class="header-anchor" href="#文件格式" aria-hidden="true">#</a></h2><p>尽管库名为<code>xlsx</code>，但它支持多种电子表格文件格式：</p><table><thead><tr><th>格式</th><th>读</th><th>写</th></tr></thead><tbody><tr><td><strong>Excel Worksheet/Workbook 格式</strong></td><td>:-----:</td><td>:-----:</td></tr><tr><td>Excel 2007+ XML Formats (XLSX/XLSM)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 2007+ Binary Format (XLSB BIFF12)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 2003-2004 XML Format (XML &quot;SpreadsheetML&quot;)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 97-2004 (XLS BIFF8)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 5.0/95 (XLS BIFF5)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 4.0 (XLS/XLW BIFF4)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 3.0 (XLS BIFF3)</td><td>✔</td><td>✔</td></tr><tr><td>Excel 2.0/2.1 (XLS BIFF2)</td><td>✔</td><td>✔</td></tr><tr><td><strong>Excel支持的文本格式</strong></td><td>:-----:</td><td>:-----:</td></tr><tr><td>Delimiter-Separated Values (CSV/TXT)</td><td>✔</td><td>✔</td></tr><tr><td>Data Interchange Format (DIF)</td><td>✔</td><td>✔</td></tr><tr><td>Symbolic Link (SYLK/SLK)</td><td>✔</td><td>✔</td></tr><tr><td>Lotus Formatted Text (PRN)</td><td>✔</td><td>✔</td></tr><tr><td>UTF-16 Unicode Text (TXT)</td><td>✔</td><td>✔</td></tr><tr><td><strong>其他Workbook/Worksheet格式</strong></td><td>:-----:</td><td>:-----:</td></tr><tr><td>Numbers 3.0+ / iWork 2013+ Spreadsheet (NUMBERS)</td><td>✔</td><td>✔</td></tr><tr><td>OpenDocument Spreadsheet (ODS)</td><td>✔</td><td>✔</td></tr><tr><td>Flat XML ODF Spreadsheet (FODS)</td><td>✔</td><td>✔</td></tr><tr><td>Uniform Office Format Spreadsheet (标文通 UOS1/UOS2)</td><td>✔</td><td></td></tr><tr><td>dBASE II/III/IV / Visual FoxPro (DBF)</td><td>✔</td><td>✔</td></tr><tr><td>Lotus 1-2-3 (WK1/WK3)</td><td>✔</td><td>✔</td></tr><tr><td>Lotus 1-2-3 (WKS/WK2/WK4/123)</td><td>✔</td><td></td></tr><tr><td>Quattro Pro Spreadsheet (WQ1/WQ2/WB1/WB2/WB3/QPW)</td><td>✔</td><td></td></tr><tr><td>Works 1.x-3.x DOS / 2.x-5.x Windows Spreadsheet (WKS)</td><td>✔</td><td></td></tr><tr><td>Works 6.x-9.x Spreadsheet (XLR)</td><td>✔</td><td></td></tr><tr><td><strong>Other Common Spreadsheet Output Formats</strong></td><td>:-----:</td><td>:-----:</td></tr><tr><td>HTML Tables</td><td>✔</td><td>✔</td></tr><tr><td>Rich Text Format tables (RTF)</td><td></td><td>✔</td></tr><tr><td>Ethercalc Record Format (ETH)</td><td>✔</td><td>✔</td></tr></tbody></table><p>给定一个不支持的文件格式则不会被写入。具有范围限制的格式将被自动截断：</p><table><thead><tr><th>格式</th><th>末尾单元格</th><th>最大列</th><th>最大行</th></tr></thead><tbody><tr><td>Excel 2007+ XML Formats (XLSX/XLSM)</td><td>XFD1048576</td><td>16384</td><td>1048576</td></tr><tr><td>Excel 2007+ Binary Format (XLSB BIFF12)</td><td>XFD1048576</td><td>16384</td><td>1048576</td></tr><tr><td>Excel 97-2004 (XLS BIFF8)</td><td>IV65536</td><td>256</td><td>65536</td></tr><tr><td>Excel 5.0/95 (XLS BIFF5)</td><td>IV16384</td><td>256</td><td>16384</td></tr><tr><td>Excel 4.0 (XLS BIFF4)</td><td>IV16384</td><td>256</td><td>16384</td></tr><tr><td>Excel 3.0 (XLS BIFF3)</td><td>IV16384</td><td>256</td><td>16384</td></tr><tr><td>Excel 2.0/2.1 (XLS BIFF2)</td><td>IV16384</td><td>256</td><td>16384</td></tr><tr><td>Lotus 1-2-3 R2 - R5 (WK1/WK3/WK4)</td><td>IV8192</td><td>256</td><td>8192</td></tr><tr><td>Lotus 1-2-3 R1 (WKS)</td><td>IV2048</td><td>256</td><td>2048</td></tr></tbody></table><p>Excel 2003 SpreadsheetML范围限制由Excel版本管理，编写者不强制执行</p><h2 id="许可" tabindex="-1">许可 <a class="header-anchor" href="#许可" aria-hidden="true">#</a></h2><p>有关详细信息，请参阅随附的许可证文件。原始作者保留Apache 2.0许可证未明确授予的所有权利</p></div></div><!----></main><!--[--><!--]--><footer class="VPContentDocFooter" data-v-6971fa12 data-v-716919ab><a class="prev-link" href="/vite-vue-blog/notes/4.library/node%E5%8C%85/%E8%84%9A%E6%9C%AC.html" data-v-716919ab><span class="desc" data-v-716919ab><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-link-icon" data-v-716919ab><path d="M15,19c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4l6-6c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4L10.4,12l5.3,5.3c0.4,0.4,0.4,1,0,1.4C15.5,18.9,15.3,19,15,19z"></path></svg> 上一节</span><span class="title" data-v-716919ab>脚本</span></a><a class="next-link" href="/vite-vue-blog/notes/4.library/xlsx/2.%E5%AD%A6%E4%B9%A0xlsx.html" data-v-716919ab><span class="desc" data-v-716919ab>下一节 <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="vt-link-icon" data-v-716919ab><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></span><span class="title" data-v-716919ab>学习xlsx</span></a></footer></div></div></div></div><div class="visually-hidden" aria-live="polite" data-v-73d720b3>js-XLSX has loaded</div></div></div>
    <script>__VP_HASH_MAP__ = JSON.parse("{\"index.md\":\"a7119076\",\"notes_1.javascript_typescript_1.介绍与安装.md\":\"bd6528cc\",\"notes_1.javascript_typescript_2.基础语法.md\":\"2b48285d\",\"notes_1.javascript_typescript_3.进阶语法.md\":\"9fc200ea\",\"notes_1.javascript_typescript_4.综合示例.md\":\"b2cca1bb\",\"notes_1.javascript_typescript_6.type-challenges.md\":\"ad1ea441\",\"notes_1.javascript_typescript_7.doc注释法.md\":\"6da3a8f5\",\"notes_1.javascript_typescript_8.tsconfig.md\":\"3a9cad49\",\"notes_1.javascript_基础_1.基础语法.md\":\"53042640\",\"notes_1.javascript_基础_10.call-apply-bind.md\":\"8b5b4d53\",\"notes_1.javascript_基础_12.date.md\":\"8bbc9e82\",\"notes_1.javascript_基础_14.正则表达式.md\":\"dad2455a\",\"notes_1.javascript_基础_15.promise.md\":\"523683bd\",\"notes_1.javascript_基础_2.string.md\":\"9ef7d4a4\",\"notes_1.javascript_基础_20.ajax.md\":\"3c505745\",\"notes_1.javascript_基础_3.number.md\":\"673ae25b\",\"notes_1.javascript_基础_4.object.md\":\"c3c2d806\",\"notes_1.javascript_基础_5.array.md\":\"8341e3ea\",\"notes_1.javascript_基础_6.canvas.md\":\"5b3d57a6\",\"notes_1.javascript_基础_es6.md\":\"a11b1af7\",\"notes_1.javascript_基础_settimeout.md\":\"3a278b83\",\"notes_1.javascript_基础_事件委托.md\":\"fa7b0a71\",\"notes_1.javascript_基础_事件循环.md\":\"043fd67b\",\"notes_1.javascript_基础_原型与原型链.md\":\"85f423d2\",\"notes_1.javascript_基础_原型链探究.md\":\"7ab3569c\",\"notes_1.javascript_基础_大文件上传分片.md\":\"e732af31\",\"notes_1.javascript_基础_懒加载和虚拟滚动.md\":\"6ff4061a\",\"notes_1.javascript_基础_文件二进制.md\":\"0b60ff5e\",\"notes_1.javascript_基础_深浅拷贝.md\":\"1d99a497\",\"notes_1.javascript_基础_闭包.md\":\"4d9e0010\",\"notes_1.javascript_基础_防抖与节流.md\":\"ac94b2d6\",\"notes_1.javascript_工具函数_10.工具函数.md\":\"8ff9a8d5\",\"notes_1.javascript_工具函数_16.滚动.md\":\"3343e4be\",\"notes_1.javascript_工具函数_svg.md\":\"8296350c\",\"notes_2.basic_1.html_1.基础.md\":\"dcdaee52\",\"notes_2.basic_2.css_1.基础.md\":\"7ace2c5c\",\"notes_2.basic_2.css_2.flex.md\":\"c69977d3\",\"notes_2.basic_2.css_3.less.md\":\"a501b0d7\",\"notes_2.basic_2.css_4.scss.md\":\"7f9633f1\",\"notes_2.basic_2.css_5.响应式.md\":\"036701f5\",\"notes_2.basic_2.css_6.主题切换.md\":\"0c4e4dd0\",\"notes_2.basic_2.css_7.动画.md\":\"fd4bc61e\",\"notes_2.basic_2.css_8.grid.md\":\"bdc8b7ae\",\"notes_2.basic_5.node_1.起步.md\":\"e7e277ef\",\"notes_2.basic_5.node_4.环境变量设置.md\":\"a03a948a\",\"notes_2.basic_5.node_npm.md\":\"211fbec4\",\"notes_2.basic_5.node_nvm.md\":\"e3486de6\",\"notes_2.basic_5.node_package.json.md\":\"d9e9c604\",\"notes_2.basic_5.node_pnpm.md\":\"bc13810e\",\"notes_2.basic_5.node_yarn.md\":\"56fb8e96\",\"notes_2.basic_5.node_脚本开发.md\":\"b2f2b588\",\"notes_2.basic_6.http_2.http.md\":\"07ef7cc3\",\"notes_2.basic_6.http_untitled.md\":\"0bf853ff\",\"notes_2.basic_7.git_github.md\":\"4a8e9177\",\"notes_2.basic_7.git_vim编辑器.md\":\"7feb6977\",\"notes_2.basic_7.git_分支操作.md\":\"eca5274c\",\"notes_2.basic_7.git_基础.md\":\"13f2197d\",\"notes_2.basic_7.git_子模块.md\":\"4d22ac99\",\"notes_2.basic_7.git_拉取代码.md\":\"1ddaa4e1\",\"notes_2.basic_7.git_提交代码.md\":\"60f0513e\",\"notes_2.basic_7.git_问题整理.md\":\"5ee1ccd8\",\"notes_2.basic_8.java_1.起步.md\":\"cd36d569\",\"notes_2.basic_8.java_3.基础语法.md\":\"b06281a7\",\"notes_2.basic_8.java_4.javaweb.md\":\"ae639163\",\"notes_2.basic_8.java_5.mysql.md\":\"c0605455\",\"notes_2.basic_8.java_6.服务器.md\":\"1fdae0b4\",\"notes_2.basic_9.算法_1.基础.md\":\"fa3f4620\",\"notes_2.basic_9.算法_5.leecode.md\":\"5836668f\",\"notes_3.framework_10.react_1.项目创建与配置.md\":\"a13b8d18\",\"notes_3.framework_10.react_2.语法.md\":\"945be494\",\"notes_3.framework_10.react_3.react-router.md\":\"89475651\",\"notes_3.framework_10.react_4.hooks.md\":\"93d27fd6\",\"notes_3.framework_3.express_1.起步.md\":\"582569a2\",\"notes_3.framework_3.express_2.express方法.md\":\"297b2f45\",\"notes_3.framework_3.express_3.jwt.md\":\"e5f91a6a\",\"notes_3.framework_3.express_4.mysql.md\":\"4f576728\",\"notes_3.framework_3.vue_12.vitepress.md\":\"03a09f4d\",\"notes_3.framework_3.vue_13.vue-router.md\":\"64d860a1\",\"notes_3.framework_3.vue_14.vuetify.md\":\"b8c63df7\",\"notes_3.framework_3.vue_15.源码阅读.md\":\"3b7203db\",\"notes_3.framework_3.vue_16.vite插件开发.md\":\"592c82ee\",\"notes_3.framework_3.vue_18.vueuse.md\":\"7292fe8e\",\"notes_3.framework_3.vue_2.vite.md\":\"66d9c036\",\"notes_3.framework_3.vue_3.基础.md\":\"189184b0\",\"notes_3.framework_3.vue_4.vue2.md\":\"6bd4d84f\",\"notes_3.framework_3.vue_5.vue3.md\":\"da43c351\",\"notes_3.framework_3.vue_6.pinna.md\":\"431f4d88\",\"notes_3.framework_3.vue_7.待整理笔记.md\":\"b5cb4a1d\",\"notes_3.framework_3.vue_8.功能实现.md\":\"deed1460\",\"notes_3.framework_4.uniapp_1.创建项目.md\":\"76affd27\",\"notes_3.framework_4.uniapp_3.实例.md\":\"c5d614e0\",\"notes_3.framework_4.uniapp_4.unicloud.md\":\"2a35fe9c\",\"notes_3.framework_4.uniapp_6.sqlite.md\":\"36191099\",\"notes_3.framework_4.uniapp_hbuilderx插件.md\":\"4bec2ec3\",\"notes_3.framework_4.uniapp_app端文件操作.md\":\"95db967d\",\"notes_3.framework_4.uniapp_nvue.md\":\"625f242d\",\"notes_3.framework_4.uniapp_功能实现.md\":\"0d913121\",\"notes_3.framework_4.uniapp_图片操作.md\":\"1d8b7462\",\"notes_3.framework_4.uniapp_基础知识.md\":\"70124264\",\"notes_3.framework_4.uniapp_小程序.md\":\"0d38f31a\",\"notes_3.framework_4.uniapp_文件操作.md\":\"e86ee38f\",\"notes_3.framework_4.uniapp_滚动.md\":\"97780f32\",\"notes_3.framework_5.electron_1.起步.md\":\"1fa8d3e9\",\"notes_3.framework_5.electron_2.vite-electron.md\":\"30b0f6fe\",\"notes_3.framework_5.electron_2.开始.md\":\"f25811cd\",\"notes_3.framework_5.electron_4.语法.md\":\"cd7644d7\",\"notes_3.framework_5.electron_5.electron打包vue.md\":\"07404ad8\",\"notes_3.framework_5.electron_6.进程通信.md\":\"172975e9\",\"notes_3.framework_5.electron_7.黑夜模式.md\":\"0acdd76f\",\"notes_3.framework_5.electron_8.browserwindow.md\":\"79092934\",\"notes_3.framework_6.微信小程序_1.创建项目.md\":\"43e386d1\",\"notes_3.framework_7.乾坤_1.前置知识.md\":\"87448ab1\",\"notes_3.framework_7.乾坤_2.实战.md\":\"ba1ae36b\",\"notes_3.framework_7.乾坤_3.部署上线.md\":\"3b3e834c\",\"notes_3.framework_7.乾坤_4.源码阅读.md\":\"c21a2e17\",\"notes_3.framework_koa_redis.md\":\"bba89871\",\"notes_3.framework_koa_中间件.md\":\"2ca1c619\",\"notes_3.framework_koa_基础.md\":\"374c2d17\",\"notes_4.library_autoprefixer_1.基础.md\":\"a15e218d\",\"notes_4.library_monaco-editor_monaco-editor.md\":\"57b75b84\",\"notes_4.library_eharts_1.vue中使用.md\":\"cdde4646\",\"notes_4.library_eharts_2.react中使用.md\":\"2579c725\",\"notes_4.library_eharts_3.通用.md\":\"cb7119c9\",\"notes_4.library_eharts_4.饼图.md\":\"4e8e47e2\",\"notes_4.library_eharts_5.柱状图.md\":\"70d08ba6\",\"notes_4.library_eharts_6.折线图.md\":\"ae2e9342\",\"notes_4.library_eharts_7.tooltip.md\":\"114afe2d\",\"notes_4.library_eharts_8.地图.md\":\"8696e214\",\"notes_4.library_logic-flow_1.起步.md\":\"f29527ec\",\"notes_4.library_logic-flow_3.用法.md\":\"d74d70e6\",\"notes_4.library_node包_cheerio.md\":\"c589ee05\",\"notes_4.library_node包_docsify.md\":\"784484ef\",\"notes_4.library_node包_npm-check.md\":\"1ce5454f\",\"notes_4.library_node包_npm-run-all.md\":\"91276b49\",\"notes_4.library_node包_tsup.md\":\"9cf1bf37\",\"notes_4.library_node包_脚本.md\":\"b58b5982\",\"notes_4.library_xlsx_1.文档翻译.md\":\"12943aa2\",\"notes_4.library_xlsx_2.学习xlsx.md\":\"e5e24bbb\",\"notes_4.library_待整理_axios.md\":\"5a7641af\",\"notes_4.library_待整理_dayjs.md\":\"7e7716a5\",\"notes_4.library_待整理_prettier.md\":\"d7bd12d2\",\"notes_4.library_待整理_vxe-table.md\":\"ed1fef55\",\"notes_5.build_1.webpack_1.起步.md\":\"8dd80bd5\",\"notes_5.build_1.webpack_2.loader.md\":\"ec110bce\",\"notes_5.build_1.webpack_3.vue脚手架.md\":\"ffb3d85e\",\"notes_5.build_1.webpack_4.进阶.md\":\"05b3507c\",\"notes_5.build_2.rollup_1.介绍.md\":\"70b92034\",\"notes_5.build_2.rollup_1.起步.md\":\"2c4acac4\",\"notes_5.build_2.rollup_4.打包格式.md\":\"cce455ff\",\"notes_5.build_2.rollup_5.常用插件.md\":\"d9ca29f7\",\"notes_5.build_2.rollup_6.插件开发.md\":\"a8a79b98\",\"notes_5.build_3.babel_3.babel.md\":\"c919cbf8\",\"notes_5.build_4.server_4.上线.md\":\"d50d068a\",\"notes_6.all_3.just-start_2.mongodb.md\":\"a068a2e5\",\"notes_6.all_3.just-start_3.移动端.md\":\"fd479c00\",\"notes_6.all_3.just-start_5.脚本.md\":\"b0c9f691\",\"notes_6.all_4.solve-problems_postmon.md\":\"844774bd\",\"notes_6.all_4.solve-problems_ps.md\":\"bdc89237\",\"notes_6.all_4.solve-problems_typora.md\":\"b10b94a2\",\"notes_6.all_4.solve-problems_uniapp.md\":\"4fd2f730\",\"notes_6.all_4.solve-problems_windows10.md\":\"b2413012\",\"notes_6.all_4.solve-problems_开发.md\":\"104171f2\",\"notes_6.all_4.solve-problems_浏览器.md\":\"af324a8b\",\"notes_6.all_4.solve-problems_论文查重.md\":\"c3cec84e\",\"notes_6.all_4.vscode_1.vscode使用.md\":\"ac6e101a\",\"notes_6.all_4.vscode_1.插件开发流程.md\":\"c7250214\",\"notes_6.all_4.vscode_1.概括.md\":\"1d9fd058\",\"notes_6.all_4.vscode_2.commands.md\":\"17839438\",\"notes_6.all_4.vscode_2.languages.md\":\"ad36adc9\",\"notes_6.all_4.vscode_2.vscode常用插件.md\":\"f856d76a\",\"notes_6.all_4.vscode_2.语法高亮指南.md\":\"022760aa\",\"notes_6.all_4.vscode_4.插件api.md\":\"d2bc7b97\",\"notes_6.all_4.vscode_5.插件开发实例.md\":\"56b1b964\",\"notes_6.all_4.vscode_6.package.json.md\":\"bd15bba9\",\"notes_6.all_english_学习学习.md\":\"8487d588\",\"notes_6.all_snabbdom_1.源码解读.md\":\"86622f05\"}")</script>
    <script type="module" async src="/vite-vue-blog/assets/app.864f9b59.js"></script>
    
  </body>
</html>